Haskell: Why aren't infix type constructors allowed?

后端 未结 2 1714
离开以前
离开以前 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:36

    It's not part of the Haskell standard, but as jamshidh mentions it is still possible in GHC. The caveat is that data constructors (not type constructors) must start with a colon:

    {-# LANGUAGE TypeOperators #-}
    
    data a + b = a :+ b
    
    f :: a + b -> a
    f (a :+ b) = a
    
    g :: a + b -> b
    g (a :+ b) = b
    

提交回复
热议问题