[Haskell-beginners] cyclic dependency problem
Francesco Ariis
fa-ml at ariis.it
Thu Mar 5 13:54:13 UTC 2015
On Thu, Mar 05, 2015 at 03:43:30PM +0200, Konstantin Saveljev wrote:
> I'm having some trouble with cyclic dependency.
>
> [..]
>
> So if I have a single module:
>
> data A a = A (StateT MyState IO a) deriving (...)
> data MyState = MyState { st :: SomeType, ... }
> data SomeType = SomeType { f :: A (), ... }
>
> With this setup the compiler is gonna tell us it doesn't know about
> MyState. And no matter how we shuffle these types within a file we are
> still getting some "unknowns"
Hello Konstantin. I just tried to feed this to ghci:
data StateT a b = StateT a b
data A a = A (StateT MyState (IO a))
data MyState = MyState { st :: SomeType }
data SomeType = SomeType { f :: A () }
and it works. I think the deriving clause is causing problems (not
surprisingly); writing the instance out yourself should solve it.
More information about the Beginners
mailing list