[Haskell-cafe] fst and snd as record selectors

Lemming schlepptop at henning-thielemann.de
Sun Oct 24 05:47:50 EDT 2004


The pair data type is quite a regular data type, where (x,y) is 
syntactic sugar for (,) x y, right?
So, why aren't 'fst' and 'snd' record selectors of the pair data type? 
The definition of pair could be like

data (,) a b = (,) {fst :: a, snd :: b}

Then the following would work:

Prelude> let a = (1,2)
Prelude> a {fst = 3}
(3,2)





More information about the Haskell-Cafe mailing list