Ghc: partially compile Haskell code?

前提是你 提交于 2019-12-30 02:47:10

问题


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. It's very nice: I can play around with :t to figure out the type of various expressions.

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. 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.

But this is so tedious! Is there a better workflow for "partially compiling" a Haskell source code?


回答1:


As @MikhailGlushenkov pointed out in the comments, the solution is to use the -fdefer-type-errors flag to GHCi.



来源:https://stackoverflow.com/questions/27780282/ghc-partially-compile-haskell-code

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