Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. cyclic dependency problem (Konstantin Saveljev)
2. Re: cyclic dependency problem (Francesco Ariis)
3. Re: cyclic dependency problem ([email protected])
4. Re: cyclic dependency problem (Konstantin Saveljev)
5. Re: cyclic dependency problem (Konstantin Saveljev)
----------------------------------------------------------------------
Message: 1
Date: Thu, 5 Mar 2015 15:43:30 +0200
From: Konstantin Saveljev <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] cyclic dependency problem
Message-ID:
<cakncejpifcf2ma_epfwhcumces_jtpimggmgbzqlpocqatu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hello,
I'm having some trouble with cyclic dependency.
My simplified version of hierarchy:
module A where
import MyState
data A a = A (StateT MyState IO a) deriving (...)
Now there is a module MyState:
module MyState where
import SomeType
data MyState = MyState { st :: SomeType, ... }
Finally the module that introduces cyclic dependency:
module SomeType where
import A
data SomeType = SomeType { f :: A (), ... }
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"
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"
How would one approach such a problem?
Best regards,
Konstantin
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150305/5d062b15/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 5 Mar 2015 14:54:13 +0100
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] cyclic dependency problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
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.
------------------------------
Message: 3
Date: Thu, 5 Mar 2015 09:25:03 -0500
From: [email protected]
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: [Haskell-beginners] cyclic dependency problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
El Mar 5, 2015, a las 8:43, Konstantin Saveljev <[email protected]>
escribi?:
> Hello,
>
> I'm having some trouble with cyclic dependency.
>
> My simplified version of hierarchy:
>
> module A where
>
> import MyState
>
> data A a = A (StateT MyState IO a) deriving (...)
>
> Now there is a module MyState:
>
> module MyState where
>
> import SomeType
>
> data MyState = MyState { st :: SomeType, ... }
>
> Finally the module that introduces cyclic dependency:
>
> module SomeType where
>
> import A
>
> data SomeType = SomeType { f :: A (), ... }
>
> 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"
>
> 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"
>
Did you try it? It should work fine -- haskell doesn't care about the order of
data declarations within a file.
Tom
> How would one approach such a problem?
>
> Best regards,
> Konstantin
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
Message: 4
Date: Thu, 5 Mar 2015 16:37:02 +0200
From: Konstantin Saveljev <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] cyclic dependency problem
Message-ID:
<CAKncEjrZWtZMypQcxqXY3R=H+1T2D=ryne4fq4nkfp3pz7v...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I believe Francesco has a point here. I do have "deriving (MonadState
MyState)" which is probably causing the problem.
Unfortunately I'm not capable of writing the instance myself. Maybe someone
could help me?
My full declaration looks something like this:
newtype X a = X (StateT MyState (ExceptT String IO) a)
deriving (Functor, Applicative, Monad, MonadIO,
MonadError String, MonadState MyState)
If I was to remove "MonadState MyState" from the "deriving" section, how
would one implement it?
Konstantin
On Thu, Mar 5, 2015 at 4:25 PM, <[email protected]> wrote:
>
>
> El Mar 5, 2015, a las 8:43, Konstantin Saveljev <
> [email protected]> escribi?:
>
> > Hello,
> >
> > I'm having some trouble with cyclic dependency.
> >
> > My simplified version of hierarchy:
> >
> > module A where
> >
> > import MyState
> >
> > data A a = A (StateT MyState IO a) deriving (...)
> >
> > Now there is a module MyState:
> >
> > module MyState where
> >
> > import SomeType
> >
> > data MyState = MyState { st :: SomeType, ... }
> >
> > Finally the module that introduces cyclic dependency:
> >
> > module SomeType where
> >
> > import A
> >
> > data SomeType = SomeType { f :: A (), ... }
> >
> > 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"
> >
> > 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"
> >
>
> Did you try it? It should work fine -- haskell doesn't care about the
> order of data declarations within a file.
>
> Tom
>
>
> > How would one approach such a problem?
> >
> > Best regards,
> > Konstantin
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150305/359f103a/attachment-0001.html>
------------------------------
Message: 5
Date: Thu, 5 Mar 2015 16:50:43 +0200
From: Konstantin Saveljev <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] cyclic dependency problem
Message-ID:
<CAKncEjr8-x8zeVA3pkW0=mos_vtuep7ezsn53tytnvlptp_...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Would this be a correct implementation?:
{-# LANGUAGE MultiParamTypeClasses #-} -- for some reason compiler says
to use it ?
import qualified Control.Monad.State.Lazy as Lazy
instance MonadState MyState X where
get = X Lazy.get
put s = X $ Lazy.put s
Konstantin
On Thu, Mar 5, 2015 at 4:37 PM, Konstantin Saveljev <
[email protected]> wrote:
> I believe Francesco has a point here. I do have "deriving (MonadState
> MyState)" which is probably causing the problem.
>
> Unfortunately I'm not capable of writing the instance myself. Maybe
> someone could help me?
>
> My full declaration looks something like this:
>
> newtype X a = X (StateT MyState (ExceptT String IO) a)
> deriving (Functor, Applicative, Monad, MonadIO,
> MonadError String, MonadState MyState)
>
> If I was to remove "MonadState MyState" from the "deriving" section, how
> would one implement it?
>
>
> Konstantin
>
> On Thu, Mar 5, 2015 at 4:25 PM, <[email protected]> wrote:
>
>>
>>
>> El Mar 5, 2015, a las 8:43, Konstantin Saveljev <
>> [email protected]> escribi?:
>>
>> > Hello,
>> >
>> > I'm having some trouble with cyclic dependency.
>> >
>> > My simplified version of hierarchy:
>> >
>> > module A where
>> >
>> > import MyState
>> >
>> > data A a = A (StateT MyState IO a) deriving (...)
>> >
>> > Now there is a module MyState:
>> >
>> > module MyState where
>> >
>> > import SomeType
>> >
>> > data MyState = MyState { st :: SomeType, ... }
>> >
>> > Finally the module that introduces cyclic dependency:
>> >
>> > module SomeType where
>> >
>> > import A
>> >
>> > data SomeType = SomeType { f :: A (), ... }
>> >
>> > 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"
>> >
>> > 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"
>> >
>>
>> Did you try it? It should work fine -- haskell doesn't care about the
>> order of data declarations within a file.
>>
>> Tom
>>
>>
>> > How would one approach such a problem?
>> >
>> > Best regards,
>> > Konstantin
>> > _______________________________________________
>> > Beginners mailing list
>> > [email protected]
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150305/a4d49e53/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 81, Issue 24
*****************************************