[英]Template Haskell: reify in GHCi
Is it somehow possible to do reify in GHCi? 是它在某种程度上可以做到具体化在GHCI?
When I try it using 'runQ' it complains "can not do reify in the IO monad". 当我使用'runQ'尝试它时,它抱怨“无法在IO monad中进行实现”。
>>> runQ (reify ''Bool)
Template Haskell error: Can't do `reify' in the IO monad
*** Exception: user error (Template Haskell failure)
I'm not looking for :t
or something, only for a way to quickly check what reify
returns without writing it to a file and loading that file into GHCi. 我不是在寻找:t
或者什么东西,只是为了快速检查reify
返回的方式而不将其写入文件并将该文件加载到GHCi中。
You just have to run it from a splice instead of using runQ
: 你只需要从拼接而不是使用runQ
运行它:
> $(stringE . show =<< reify ''Bool)
"TyConI (DataD [] GHC.Types.Bool [] [NormalC GHC.Types.False [],NormalC GHC.Types.True []] [])"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.