[英]Ghc: partially compile Haskell code?
When I compile a Haskell file with ghci
, typically with :load
, and if there is no type error, all the expressions are loaded in the ghc interpreter. 当我使用
ghci
(通常使用:load
编译Haskell文件时,如果没有类型错误,则所有表达式都将加载到ghc解释器中。 It's very nice: I can play around with :t
to figure out the type of various expressions. 很好:我可以使用
:t
来找出各种表达式的类型。
My problem is: if there is a tiny error somewhere, ghci is not able to load anything (not even the imported modules!!), which makes finding the right types even more difficult. 我的问题是:如果某个地方存在微小错误,ghci将无法加载任何内容 (甚至导入的模块也无法加载!),这使得找到正确的类型变得更加困难。 I always do the same: comment out all the bits that do not typecheck, find the relevant types wiht
:t
in ghci, and de-comment. 我总是这样做:注释掉所有不进行类型检查的位,用ghci中的
:t
查找相关类型,然后进行注释。
But this is so tedious! 但这是如此乏味! Is there a better workflow for "partially compiling" a Haskell source code?
是否有更好的工作流程来“部分编译” Haskell源代码?
正如@MikhailGlushenkov在评论中指出的那样,解决方案是对GHCi使用-fdefer-type-errors
标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.