How can I get `ghci` to use my `show` function?

独自空忆成欢 提交于 2019-12-06 22:20:39

问题


Let's say you want to use your own show function (for example, let show = take 1000 . Prelude.show). How can you allow ghci to use that for printing instead of the built in show?


回答1:


You can define your own interactive print function e.g:

module BetterPrint
betterPrint a = putStrLn (take 1000 $ show a)

then start ghci as

ghci -interactive-print=BetterPrint.betterPrint


来源:https://stackoverflow.com/questions/35613612/how-can-i-get-ghci-to-use-my-show-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!