用户使用/避免哪些Haskell(GHC)扩展? [英] Which Haskell (GHC) extensions should users use/avoid?

查看:222
本文介绍了用户使用/避免哪些Haskell(GHC)扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我已经有几次让GHC告诉我使用扩展的经验,只是发现当使用扩展时,当简单的重构允许我坚持使用Haskell时,我已经使代码更加复杂98(现在 2010 ),并有一个更直接的解决方案。另一方面,有时候GADT或Rank2Types(很少RankNTypes)会使工作更少,代码更简洁。

哪些扩展一般会掩盖更好设计的可能性,并且通常会改进它?如果有两者兼而有之,那么在决定使用该扩展之前,用户应该寻找什么(确定他们打算的解决方案是真是假)?



(另请参阅我应该使用GHC Haskell扩展吗?

解决方案

道德上的良好扩展和道德上坏的特别列表 - 这是审美判断!




  • GADT li>
  • 并行列表解析

  • 模式守卫

  • Monad解析

  • 元组部分

  • 记录通配符

  • 空数据删除

  • 存在类型
  • 广义新类型派生

  • MPTCs + FDs

  • 类型系列

  • 显式量化
  • >
  • 更高等级的多态性

  • 词汇






    >


    • SQL解析

    • 隐式参数


    丑陋(但必需)


    • 模板Haskell

    • 取消装箱的类型和元组
    • 不可判定的,重叠的和不连贯的实例 - 通常意味着您有错误的设计。



    不确定


    • 箭头符号 li>查看模式


    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.

    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?

    (See also Should I use GHC Haskell extensions or not?)

    解决方案

    An ad hoc list of morally "good" extensions, and morally "bad" ones - this is an aesthetic judgement!

    The Good

    • GADTs
    • Parallel list comprehensions
    • Pattern guards
    • Monad comprehensions
    • Tuple sections
    • Record wild cards
    • Empty data decls
    • Existential types
    • Generalized new type deriving
    • MPTCs + FDs
    • Type families
    • Explicit quantification
    • Higher rank polymorphism
    • Lexically scoped tyvars
    • Bang Patterns

    The Bad

    • SQL comprehensions
    • Implicit parameters

    The Ugly (but necessary)

    • Template Haskell
    • Unboxed types and tuples
    • Undecidable, overlapping and incoherent instances -- usually means you have a misdesign.

    Not sure

    • Arrow notation
    • View patterns

    这篇关于用户使用/避免哪些Haskell(GHC)扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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