用户应该使用/避免哪些 Haskell (GHC) 扩展? [英] Which Haskell (GHC) extensions should users use/avoid?
问题描述
我有过几次让 GHC 告诉我使用扩展的经验,结果发现在使用该扩展时,我使代码变得更加复杂,而一个简单的重构就可以让我坚持使用 Haskell98(现在 2010)并且有一个更直接的解决方案.
I have had the experience a few times now of having GHC tell me to use an extension, only to discover that when in using that extension I have made code far more complex when a simple refactor would have allowed me to stick with Haskell 98 (now 2010) and have a more straightforward solution.
另一方面,有时 GADT 或 Rank2Types(很少是 RankNTypes)的工作量要少得多,代码也更干净.
On the other hand, there are also times when GADT's or Rank2Types (rarely RankNTypes) make for much less work and much cleaner code.
哪些扩展通常会掩盖更好设计的可能性,哪些通常会改进它?如果有一些两者兼而有之,那么在决定使用该扩展程序之前,用户应该寻找什么(确保他们想要的解决方案是真的还是假的)?
Which extensions tend generally to obscure the possibility of a better design, and which generally improve it? If there are some that do both, what should a user look for (be sure it true or not true of the solution they are intending) before deciding to use that extension?
推荐答案
道德好"扩展和道德坏"扩展的临时列表 - 这是审美判断!
An ad hoc list of morally "good" extensions, and morally "bad" ones - this is an aesthetic judgement!
优点
- GADTs
- 平行列表推导式
- 模式守卫
- Monad 理解
- 元组部分
- 记录通配符
- 空数据声明
- 存在类型
- 广义的新类型推导
- MPTC + FD
- 类型家族
- 显式量化
- 更高等级的多态性
- 词法范围的 tyvars
- 刘海图案
坏处
- SQL 理解
- 隐式参数
丑陋的(但必要)
- Haskell 模板
- 未装箱的类型和元组
- 无法确定、重叠和不连贯的实例 -- 通常意味着您的设计有误.
不确定
- 箭头符号
- 查看模式
这篇关于用户应该使用/避免哪些 Haskell (GHC) 扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!