With -XDuplicateRecordFields
, the following is allowed:
{-# LANGUAGE DuplicateRecordFields #-}
module Baz(Foo(..), Bar(..)) where
data Foo = Foo {qux :: Int}
data Bar = Bar {qux :: String}
However, I get a compile error when Foo
is defined in a module Foo
and Bar
is defined in a module Bar
:
{-# LANGUAGE DuplicateRecordFields #-}
module Baz(Foo(..), Bar(..)) where
import Foo (Foo(..))
import Bar (Bar(..))
Conflicting exports for ‘qux’
I think what I'm trying to do is equivalent to the first example; it shouldn't matter where the data types are originally defined. Is this sort of thing supported in GHC 8?
I did post a bug here. However, I also accidentally discovered a workaround:
If I put the pragma in either Foo.hs or Bar.hs, GHC accepts the program. That is, the following compiles:
{-# LANGUAGE DuplicateRecordFields #-}
module Foo(Foo(..)) where
data Foo = Foo {qux::Int}
module Bar(Bar(..)) where
data Bar = Bar {qux::String}
module Baz(Foo(..),Bar(..)) where
import Foo (Foo(..))
import Bar (Bar(..))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With