Records in Haskell
ml at isaac.cedarswampstudios.org
Sun Feb 26 00:00:25 CET 2012
On 02/25/2012 05:10 PM, Gábor Lehel wrote:
> Could you elaborate on this? (What's the way I don't want? What do you
> mean by field-name-prefixes versus new-style overloading?) With DORF I
> have control over which fields are polymorphic over which records,
> very much like how I have control over which classes are polymorphic
> over which types. That's what I want.
Darn, I misinterpreted DORF. There was too much text and too many options.
Tell me if I'm correct:
A. Every declaration with record syntax creates Has instances for all
B. "Has", "get" and "set" may not be written by users (guessing due to
C. You create functions using "fieldLabel name [...]"
D. which have the magical effect of, when in scope unqualified, causing
data types defined with record syntax to be accessible through that
particular fieldLabel function (and no other way).
E. (When two fieldLabels of the same name are in scope unqualified,
declaring a record containing that name is an error.)
F. So adding an import (for some other reason for your code) that
happens to include a fieldLabel can make your records accidentally be
more visible, rather than be compile-error or no-effect.
I feel weird about record fields having an option that depends on
whether something's in scope and cannot be controlled syntactically.
Maybe we can fix that without making the syntax worse.
G. It is possible (but rather ugly) to use dot-notation when there are
multiple fieldNames of the same name in scope. 
Hmm. Maybe this is Haskelly as well as convenient enough. Did I get
everything right? What do you think about my concern about F?
More information about the Glasgow-haskell-users