You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
λ> :set -XOverloadedRecordDot
λ> data Person = Person { name :: String, age :: Int } deriving (Eq, Show, Ord)
λ> john = Person "John" 34
λ> john.address
<interactive>:4:1: error:
• No instance for (GHC.Records.HasField "address" Person a0)
arising from selecting the field ‘address’
• In the expression: john.address
In an equation for ‘it’: it = john.address
While this is technically a "correct" error message I believe we can do better. For example
<interactive>:4:1: error:
• Cannot select nonexistent field ‘address’
from a record of type ‘Person’
• In the expression: john.address
In an equation for ‘it’: it = john.address
Whether to mention HasField at all is perhaps a question, but I believe that if a user is advanced enough to potentially want to mess with HasField then they don't need the error message to spell that out for them.
The text was updated successfully, but these errors were encountered:
I know this issue is old, but wanted to add that - as a hobbyist Haskell user - this error popped up and it took me way too long to figure out that the actual issue was I was missing an import; the record wasn't in scope.
No instance for ‘GHC.Records.HasField
"login" Persist.User.User String’
arising from selecting the field ‘login’
Having the error message be as suggested in the issue - and perhaps adding a little hint that the record type may not be in scope (not imported or misspelled, as with other error messages), would be very helpful.
Using GHC 9.4.4:
While this is technically a "correct" error message I believe we can do better. For example
Whether to mention
HasField
at all is perhaps a question, but I believe that if a user is advanced enough to potentially want to mess withHasField
then they don't need the error message to spell that out for them.The text was updated successfully, but these errors were encountered: