可以采取任何措施来为未定义的值定义 Show 实例吗?也许存在一些 GHC 扩展?我想要这样的东西:
> print (1,undefined)
(1,"undefined")
根据Haskell 2010 报告,第 9 章 http://www.haskell.org/onlinereport/haskell2010/haskellch9.html, 评估undefined
应该总是会导致错误:
-- It is expected that compilers will recognize this and insert error
-- messages that are more appropriate to the context in which undefined
-- appears.
undefined :: a
undefined = error "Prelude.undefined"
由于打印值包括对其进行评估,因此这总是会给出错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)