Re:Pitfalls in Haskell
by hellofunk on Monday August 22, 2016 @07:05AM
(#12335414)
Didn't GHC 8 recently released address this problem?
[ Parent
| on HN ]
Yes, but I'm going to guess that that runtime exception is still possible. Record accessors are disambiguated through type inference so if their type is ambiguous it will still fail.
I'm intrigued, which one of these problems was fixed? Unfortunately I still have to use 7.8 so it won't help me currently but in the long run it's good to know.
Using the same record field name in different records:
https://downloads.haskell.org/~ghc/master/users-guide/8.0.1-...
Technically the complaint here was of the same record field name in different constructors for the same record, which is perfectly allowed when the fields in question have the same type but not when the types differ. I don't think DuplicateRecordFields addresses this.
Re:Pitfalls in Haskell
by taylorfausak on Monday August 22, 2016 @11:56AM
(#12337203)
That's correct.
{-# LANGUAGE DuplicateRecordFields #-}
data A = B { x :: Bool }
| C { x :: Int }
Example.hs:2:1: error:
• Constructors B and C give different types for field ‘x’
• In the data type declaration for ‘A’