Records in Haskell

Johan Tibell johan.tibell at
Sat Feb 25 01:15:12 CET 2012

On Fri, Feb 24, 2012 at 3:07 PM, Barney Hilken <b.hilken at> wrote:
> But the difference is that <= is (potentially) an arbitrary function, so we need to be careful that the instances make sense. A formally correct system would insist that all instances are (at least) reflexive and transitive. But in the case of records, we know what the instances are: they are projection functions. Every single (automatically generated) instance does exactly the same thing: it projects out one component of a record. This isn't like OO polymorphism, where "messages" are actually arbitrary functions which could do anything, the polymorphism is exactly the same as that of fst and snd.

I appreciate the difference and it might be enough of a difference
(from e.g. OO systems) that the problems seen there won't show up in
Haskell under a new record system.

Aside: It is possible to have no scalar fields in records of course.
data R = C { compare :: (a -> a -> Ordering) }

-- Johan

More information about the Glasgow-haskell-users mailing list