例如。我如何打印出这样的东西:
showEntry entry = entry.lastName ++ "\t" ++
entry.firstName ++ "\t" ++
entry.phone
print(showEntry {lastName: 'Doe', firstName: 'John', phone: '555-555-5555'})
这只是打印出来Doe\tJohn\t555-555-5555。
例如。我如何打印出这样的东西:
showEntry entry = entry.lastName ++ "\t" ++
entry.firstName ++ "\t" ++
entry.phone
print(showEntry {lastName: 'Doe', firstName: 'John', phone: '555-555-5555'})
这只是打印出来Doe\tJohn\t555-555-5555。
该问题基于旧版本的语言和相关工具。如今,这是您可以做的。
使用log来自purescript-console(https://pursuit.purescript.org/packages/purescript-console/4.2.0/docs/Effect.Console#v:log)。
> import Effect.Console
> log "Hello\tSailor!"
Hello Sailor
unit
>
REPL (purs repl)show隐式使用将值编码为字符串。为了解决这个问题,可以使用 log 效果(正如 Phil Freeman 在他的评论中提到的,尽管使用 没有什么不安全的log)。