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 ->
?
(->) is often called the "function arrow" or "function type constructor", and while it does have some special syntax, there's not that much special about it. It's essentially an infix type operator. Give it two types, and it gives you the type of functions between those types.
Haskell is a functional language and it is strictly typed, which means the data type used in the entire application will be known to the compiler at compile time.
Haskell has three basic ways to declare a new type: The data declaration, which defines new data types. The type declaration for type synonyms, that is, alternative names for existing types. The newtype declaration, which defines new data types equivalent to existing ones.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With