[Haskell-cafe] Cyclic Dependencies
Georg Martius
mai99dgf at studserv.uni-leipzig.de
Wed May 12 16:03:35 EDT 2004
Hi,
I have some problems with cyclic dependencies.
Module Foo:
data Foo = Foo { bar :: Bar }
Module Bar:
class BarClass b where
barfun :: b -> Foo -> Foo
data Bar = forall b . (BarClass b) => Bar b
Obviously I have to import both modules mutually. My workaround was to add a further type variable to BarClass.
class BarClass' b f where
barfun :: b -> f -> f
data Bar' f = forall b . (BarClass' b f) => Bar b
This seams to be fine, but in my case it is a bit more compicated. I need a Read instance of Foo. Therefor I have to implement the Read instance for the existential type Bar by my own and need to know about the instanced of BarClass. Unfortunately, the instances of BarClass need Foo and I have a cycle again.
Thanks,
Georg
More information about the Haskell-Cafe
mailing list