我如何获得`ghci`来使用我的`show`功能? [英] How can I get `ghci` to use my `show` function?

查看:105
本文介绍了我如何获得`ghci`来使用我的`show`功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你想使用你自己的show函数(例如, let show = take 1000。Prelude.show )。你如何允许 ghci 用于打印而不是内置 show

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?

.html#ghc-flag - interactive-print%20%E2%9F%A8expr%E2%9F%A9rel =nofollow noreferrer>交互式打印功能例如:

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

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

然后启动ghci作为

ghci -interactive-print=BetterPrint.betterPrint

这篇关于我如何获得`ghci`来使用我的`show`功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆