While I was reading this tutorial on monads, found the following expression.
data M a = Raise Exception | Return a
type Exception = String
It says that a is used as a type variable and a range of values in Raise Exception and Return a, but I don’t understand the use (or the meaning) of M here. If M is a data type Why is it used like M a ?
Mis the name of the type constructor being defined,ais a type parameter to this constructor. To use the data type later you will have to give the constructorMand supply a type argument fora, e.g.M Int.