Records in Haskell

AntC anthony_clayden at
Tue Feb 28 12:09:58 CET 2012

Barney Hilken <b.hilken <at>> writes:

> > This should be used to generate
> > internal constraints and not be exposed to the end user and not
> > automatically abstract over fields.

Barney, I'm not going to try to defend or explain what Greg means by that 
comment, but I do want to talk about:

> insistence that the Has class should be hidden from the user.
> ...
> I think the Has class would be useful to programmers and
> no harder to understand than other Haskel classes. It should not be hidden.
> Barney.

I agree that what the `Has` class is doing is useful, and indeed the 
programmer needs to understand it.

SPJ suggested syntactic sugar for the Has class. The DORF proposal embraces it 
whole-heartedly, and expects the programmer would use the sugar. There's two 
reasons for avoiding writing explicit `Has`:

1. It's tricky syntax and easy to get wrong.
   Specifically, all your examples in later posts have confused it.
2. The implementation of overloadable record fields (whether SORF or DORF)
   is going to be tricky to get right. We'll need equality and class
   constraints. There needs to be some space for the implementors to tune
   the design.

I think the sugar is hiding the implementation, not the existence of the `Has` 
class -- as is good practice.


More information about the Glasgow-haskell-users mailing list