【发布时间】:2016-08-13 23:46:22
【问题描述】:
正如标题所说,由于某种原因,传递给trace(嗯,它的一个变体)函数的消息在调试函数时无法正确显示。简单地刷新 stdout/stderr 似乎也没有任何作用。
-- Makes it more like Haskell's trace
debug :: String -> α -> α
debug msg f = const f $ trace msg
-- dummy function
polyA :: (Num α) => α
polyA = debug "polyA\n" 0
-- another dummy function
polyB :: (Num α) => α
polyB = debug "polyB\n" polyA
main :: IO ()
main = do println (polyB :: Int )
println (polyB :: Int )
println (polyB :: Integer)
输出只是
0
0
在 stderr 中看不到任何东西(通常在 Eclipse 的控制台中用红色文本表示)。
【问题讨论】:
标签: haskell trace stderr frege