Record fields pushing each other out of scope in GHCi is unintuitive
If we try the following in GHCi:
:seti -XDuplicateRecordFields
data A = MkA { foo :: Int, bar :: Int }
data B = MkB { foo :: Int }
f r = r { foo = 3, bar = 4 }
we get an error:
<interactive>:4:7: error:
* No constructor has all these fields: `foo', `bar'
* In the expression: r {foo = 3, bar = 4}
In an equation for `f': f r = r {foo = 3, bar = 4}
This is because the definition data B = MkB { foo :: Int }
has shadowed the record field foo
of A
, making it only available under the qualifier Ghci1
. The following record update is accepted:
g r = r { Ghci1.foo = 3, bar = 4 }
I will fix in !8686 (merged).