开发者

What does :-> mean in a haskell type specification

I've seen this in a few places:

data T = T a :-> b
开发者_开发问答

Notably in quickcheck we have

data Fun a b = Fun (a :-> b, b) (a -> b)

What is the :-> and how does it differ from ->?


Operators beginning with a colon is a constructor or type name. In this case it is a type name for a data type specific to quickcheck, but in general the symbol :-> could be used for any constructor or type name as you like (it's not part of the language proper).

The definition of :-> in quickcheck:

-- the type of possibly partial concrete functions
data a :-> c where
  Pair  :: (a :-> (b :-> c)) -> ((a,b) :-> c)
  (:+:) :: (a :-> c) -> (b :-> c) -> (Either a b :-> c)
  Unit  :: c -> (() :-> c)
  Nil   :: a :-> c
  Table :: Eq a => [(a,c)] -> (a :-> c)
  Map   :: (a -> b) -> (b -> a) -> (b :-> c) -> (a :-> c)


Answered my own question: first saw this as

data Edge = i :-> i

:-> is of course the constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜