Warm tip: This article is reproduced from stackoverflow.com, please click
haskell

What does a : -> b mean in Haskell?

发布于 2020-04-04 10:11:51

I am trying to implement a dictionary in Haskell and I see that the data type must be

data Rel a b = a :-> b

but I don't see what it means, I think it's the same thing as key-value or similar

Questioner
Hernanvq
Viewed
76
40k 2020-02-01 04:08

Looks like :-> is just a fancy constructor name:

Prelude> data Rel a b = a :-> b
Prelude> :t (5 :-> 6)
(5 :-> 6) :: (Num a, Num b) => Rel a b

In this code, 5 :-> 6 produces a Rel value.

One could've used data Rel a b = a :-% b instead, for example, where :-% would be the constructor name.