<div dir="ltr">I believe Francesco has a point here. I do have "deriving (MonadState MyState)" which is probably causing the problem.<div><br></div><div>Unfortunately I'm not capable of writing the instance myself. Maybe someone could help me?</div><div><br></div><div>My full declaration looks something like this:</div><div><br></div><div><div>    newtype X a = X (StateT MyState (ExceptT String IO) a)</div><div>                    deriving (Functor, Applicative, Monad, MonadIO, MonadError String, MonadState MyState)</div></div><div><br></div><div>If I was to remove "MonadState MyState" from the "deriving" section, how would one implement it?</div><div><br></div><div><br></div><div>Konstantin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 4:25 PM,  <span dir="ltr"><<a href="mailto:amindfv@gmail.com" target="_blank">amindfv@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
El Mar 5, 2015, a las 8:43, Konstantin Saveljev <<a href="mailto:konstantin.saveljev@gmail.com">konstantin.saveljev@gmail.com</a>> escribió:<br>
<div><div class="h5"><br>
> Hello,<br>
><br>
> I'm having some trouble with cyclic dependency.<br>
><br>
> My simplified version of hierarchy:<br>
><br>
>     module A where<br>
><br>
>     import MyState<br>
><br>
>     data A a = A (StateT MyState IO a) deriving (...)<br>
><br>
> Now there is a module MyState:<br>
><br>
>     module MyState where<br>
><br>
>     import SomeType<br>
><br>
>     data MyState = MyState { st :: SomeType, ... }<br>
><br>
> Finally the module that introduces cyclic dependency:<br>
><br>
>     module SomeType where<br>
><br>
>     import A<br>
><br>
>     data SomeType = SomeType { f :: A (), ... }<br>
><br>
> I have been suggested to move the types into one module and then import it wherever needed. But the problem is that even if I put them into one file those three data types still form a cyclic dependency and compiler throws errors saying "i don't know about this"<br>
><br>
> So if I have a single module:<br>
><br>
>     data A a = A (StateT MyState IO a) deriving (...)<br>
>     data MyState = MyState { st :: SomeType, ... }<br>
>     data SomeType = SomeType { f :: A (), ... }<br>
><br>
> 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"<br>
><br>
<br>
</div></div>Did you try it? It should work fine -- haskell doesn't care about the order of data declarations within a file.<br>
<br>
Tom<br>
<span class="im HOEnZb"><br>
<br>
> How would one approach such a problem?<br>
><br>
> Best regards,<br>
> Konstantin<br>
</span><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br></div>