4 ms·
I don't know Haskell, but it seems pretty clear: "something called a Maybe named 'a'; is equal to Nothing, or just 'a' itself" (hmm, I'm not sure that's a whole
by ominous_prime 13y ago
I don't know Haskell, but it seems pretty clear: "something called a Maybe named 'a'; is equal to Nothing, or just 'a' itself" (hmm, I'm not sure that's a whole lot clearer :-/ )
- shoo 13y agoThe 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)