[Haskell-cafe] Partial record access

Georgi Lyubenov godzbanebane at gmail.com
Fri Nov 19 09:24:39 UTC 2021


Hey Cafe,

With the advent of RecordDotSyntax (or more precisely OverloadedRecordDot?)
in 9.2, I was expecting this wart to be fixed:

data Ty
  = X {x :: String}
  | Y {y :: Int}

> y $ X "lol"
*** Exception: No match in record selector y

As it seems like the perfect opportunity to introduce a breaking change for
a behaviour that is usually undesirable (in my experience).

But instead:

> :set -XOverloadedRecordDot
> (X "lol").y
*** Exception: No match in record selector y

Unfortunately, I couldn't follow and/or remember all of the discussion
around RecordDotSyntax, so this might be something I missed.

Is there a reason why we don't generate HasField x r a only when all of the
constructors for r have a field "x" :: a? If not, is the community open to
changing this, while the new extension is still ripe?

Cheers!

=======
Georgi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20211119/3fe9cbcc/attachment.html>


More information about the Haskell-Cafe mailing list