4 ms·
The line data Maybe a = Nothing | Just a introduces a new data type. Here a denotes another type which serves as a parameter (an example of a parametrized
by grn 13y ago
The line
data Maybe a = Nothing | Just a
introduces a new data type. Here a denotes another type which serves as a parameter (an example of a parametrized data type is a list; a list of integers, a list of strings, etc.). In this case we define a data type Maybe a that may contain a value of type a. On the right hand side we have type constructors. They describe different ways that can be used to construct a value of the type we're defening. Here we have two constructors: Nothing which takes no arguments and Just which takes one argument of type a.
Assume that a is the type String. Then Nothing is a value of type Maybe String but it's an empty box that contains no value. On the other hand Just "Hello, World!" is a box with the specified string inside.
Disclaimer: I'm not a Haskell expert. Feel free to correct me.