Accessing values in custom types

If your type only has one variant* you can do it like this:

type A = A Int Int

getFirst : A -> Int
getFirst (A x _) =
    x

* More precisely, if your pattern is exhaustive.

3 Likes