【发布时间】:2019-04-05 09:08:38
【问题描述】:
例如。 我如何打印出这样的东西:
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。
【问题讨论】:
-
你是如何运行这个函数的?如果您使用
psci,Show实例将转义制表符,这就是您在输出中看到\t的原因。 -
是的,我正在使用
psci。这就解释了。我想你在书中某处提到了这一点。我可以确保“\t”在打印过程中没有被转义,比如阻止 Show 实例的标准行为吗?或者完全使用不同的函数而不是print? -
对
print的调用被烘焙到psci。您可以使用不安全的 FFI 原语来调用console.log:foreign import unsafeTracing "function tracing(x) { console.log(x); return x; }" :: forall a. a -> a
标签: printing tabstop purescript