3 ms·
It's more or less the haskell version of a struct or a public class with fields and no methods, except that you can specify more than one shape for the same typ
by JulianMorrison 18y ago
It's more or less the haskell version of a struct or a public class with fields and no methods, except that you can specify more than one shape for the same type.
data MyMaybe a = Just a | Nothing
...means in Java speak "MyMaybe<a> is an abstract generic superclass with a final singleton subclass Nothing<a> having no fields, and a final subclass Just<a> having one field of type a"
You then write functions that take that data and use it.