Hi everyone,
I have two modules that share a common data type in their respective data structures:
package Aaa where
newtype Foo = Foo String
data Bar = Bar {
barFoo :: [Foo]
} deriving (Show, Eq)
...
package Bbb where
newtype Foo = Foo String
data Quux = Quux {
quuxFoo :: [Foo]
} deriving (Show, Eq)
...
Both modules require the Foo newtype defined. However, in all other respects they are separate modules that can be used independently.
Defining the newtype Foo twice, as above, throws a compilation error (ambigious reference). Importing one module inside another breaks independence. I've been including newtype Foo in a Common.hs module that is included in both, as I would in C or C++. This sort of thing can easily get more complicated as the program grows however.
I was wondering if the Haskell community has a better solution to this that I've overlooked.
Ian Knopke
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners