Records in Haskell

Oliver Batchelor saulzar at
Tue Feb 28 11:09:27 CET 2012


> Wrong: You cannot use a fieldLabel `name` declared in module/namespace A to
> access a record with a field `name` declared in module B. You'll get a 'no
> instance' compile fail. Same familiar rules as for any instance resolution.
> This is the crucial difference compared to SORF: which can't control the scope
> of its String Kind. (Apologies that I added a speculative discussion of
> whether DORF could use String Kinds. I said that if doing so would open
> the 'back door' to the abstraction, then I'll stick with types.)

Perhaps this situation could occur though?

Module A
fieldLabel name String

Module B
import A -- unknowingly picking up the name label

data Foo = Foo { name :: String } -- uses the name label by accident

So there'd have to be some syntax to make sure you intend to use a
label rather than accidentally use it?
(Not that this is a big issue, the situation is surely minor compared
to sharing unrelated labels all the time)


More information about the Glasgow-haskell-users mailing list