[section4] 1.2 - The polymorphic type constructor Maybe

The polymorphic type constructor Maybe.

data Maybe a = Nothing | Just a

Ok, we have all the conceptual tools required to understand what this means.

A value of type "Maybe int" is either something like "Just 45", or else the constant Nothing.

So it's like the class of integers, plus some special designated null value, called Nothing.

"Just int" is the specific constructor that maps the integer "n" to the value term "Just n" which in turn belongs to the class of values for "Maybe int".

"Nothing" is the constructor that picks out the fixed constant Nothing.

"Maybe" is the polymorphic type constructor that maps type "a" to type "Maybe a".

Question: How are the semantics of Nothing handled, given that the type variable is not a parameter for this constructor? How do we arrive at a different Nothing constructor, for each instance of "Maybe a"?


Sign In or Register to comment.