3 ms·
The variable 'a' there is a placeholder for a type. e.g. loosely translating the idea of Maybe to C++ syntax (perhaps more familiar?) might give something rese
by shoo 13y ago
The variable 'a' there is a placeholder for a type.
e.g. loosely translating the idea of Maybe to C++ syntax (perhaps more familiar?) might give something resembling:
Maybe<int> x = Just<int>(30);
Maybe<int> y = Nothing<int>();
x and y are values of type Maybe<int>. I.e. we've plugged in the type int for the type variable a.
Given an arbitrary value of type Maybe<int> you have two cases to consider - either it is a "Nothing" which contains no further data, or it is a "Just<int>" which contains an int value.
You can think of the type Maybe<int> as being a "nullable int" type or perhaps a special collection of ints that can only contain 0 or 1 int value.
(beware: my knowledge of both haskell & c++ is not fantastic)