Ghc:部分编译Haskell代码? [英] Ghc: partially compile Haskell code?

查看:136
本文介绍了Ghc:部分编译Haskell代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 ghci 编译Haskell文件时,通常使用:load ,并且如果没有类型错误,所有的表达式都被加载到ghc解释器中。这是非常好的:我可以玩弄:t 来找出各种表达式的类型。



我的问题是:如果某处存在一个小错误,ghci无法加载任何东西(甚至不是导入的模块!!),这使得找到合适的类型更加困难。我总是这样做:注释掉所有不需要检查的位,在ghci中找到:t 的相关类型,并且注释掉。



但这太单调乏味了!是否有更好的部分编译Haskell源代码的工作流程?

正如@MikhailGlushenkov在评论中指出的那样,解决方案是使用 -fdefer -type-errors 标志到GHCi。


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?

解决方案

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

这篇关于Ghc:部分编译Haskell代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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