Skip to content

Record types and when do they 'match'

suppose we have the following code:

f : { x: Int, y: Int } -> (Int, Int)
f p = (p.x, p.y)

f_pre_normal : { x: Int } -> Bool
f_pre_normal p = p.x == 0

type alias Point1D a = { a | x : Int }

f_pre_extensible : Point1D a -> Bool
f_pre_extensible p = p.x == 0

One could ague that { x: Int, y: Int } and { x: Int } incompatible types, as there is no way to unify them. But allowing this might sometimes be handy.

The f_pre_extensible is (of course) correct.

Edited by Kai Prott