Haskell: Why aren't infix type constructors allowed?

后端 未结 2 1712
离开以前
离开以前 2020-12-20 14:21

In the Haskell 98 report, I found this:

The syntax for Haskell type expressions is given above. Just as data values are built using data constructors,

2条回答
  •  囚心锁ツ
    2020-12-20 14:49

    Just to be completely clear: Haskell 98 and Haskell 2000 both allow infix value constructors such as

    data Complex r = r :+ r
    

    Here the value constructor (:+) is infix, as in 5 :+ 7.

    You only need the TypeOperators extension to have type constructors which are infix. For example,

    data x ??! y = Left x | Right y
    

    Here the type constructor (??!) is infix, as in Int ??! Bool.

提交回复
热议问题