Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. If I only had a brain (Amy de Buitl?ir) 2. Re: If I only had a brain (aditya siram) 3. Re: If I only had a brain (Amy de Buitl?ir) 4. Re: If I only had a brain (Amy de Buitl?ir) 5. Re: Beginners Digest, Vol 30, Issue 17 (Russ Abbott) ---------------------------------------------------------------------- Message: 1 Date: Sun, 12 Dec 2010 20:26:26 +0000 From: Amy de Buitl?ir <a...@nualeargais.ie> Subject: [Haskell-beginners] If I only had a brain To: beginners <beginners@haskell.org> Message-ID: <aanlktinfgv9+0og-ax-pjap9dv3hcdyu0r1mgb=3k...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 I have a class with some functions that have type signatures of the form (RandomGen g) => some parameter types -> RandT g (State [Neuron]) something For example: stimulate :: (RandomGen g) => Int -> [Double] -> RandT g (State [Neuron]) () That "RandT g (State [Neuron])" is my implementation of a "brain", so I'd like to call it that. I tried: data (RandomGen g) => Brain g a = RandT g (State [Neuron]) a But I got this error: `State [Neuron]' is not applied to enough type arguments Expected kind `?', but `State [Neuron]' has kind `* -> *' In the type `State [Neuron]' In the definition of data constructor `RandT' In the data type declaration for `Brain' Do I need higher ranked types or existential types in order to do that? Or am I going about this the wrong way? Thank you in advance, Amy ------------------------------ Message: 2 Date: Sun, 12 Dec 2010 14:53:20 -0600 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] If I only had a brain To: Amy de Buitl?ir <a...@nualeargais.ie> Cc: beginners <beginners@haskell.org> Message-ID: <aanlkti=7aykjlixv9dmz8zb1ln5od6j-e6kzvj42o...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Does this help? I don't know what Neuron is so I've made it an Int to get the code to compile. Other than that it is my understanding that if you just want to alias an existing type using "type ..." is better than "data ..." which creates a fresh type. Does this help? -deech {-# LANGUAGE PackageImports #-} import Control.Monad.Random import "mtl" Control.Monad.State type Neuron = Int type Brain g a = (RandomGen g) => RandT g (State [Neuron]) a stimulate :: Int -> [Double] -> Brain g () stimulate = undefined On Sun, Dec 12, 2010 at 2:26 PM, Amy de Buitl?ir <a...@nualeargais.ie> wrote: > I have a class with some functions that have type signatures of the form > > ?(RandomGen g) => some parameter types -> RandT g (State [Neuron]) something > > For example: > > ?stimulate :: (RandomGen g) => Int -> [Double] -> RandT g (State [Neuron]) () > > That "RandT g (State [Neuron])" is my implementation of a "brain", so > I'd like to call it that. I tried: > > ?data (RandomGen g) => Brain g a = RandT g (State [Neuron]) a > > But I got this error: > > ? ?`State [Neuron]' is not applied to enough type arguments > ? ?Expected kind `?', but `State [Neuron]' has kind `* -> *' > ? ?In the type `State [Neuron]' > ? ?In the definition of data constructor `RandT' > ? ?In the data type declaration for `Brain' > > Do I need higher ranked types or existential types in order to do > that? Or am I going about this the wrong way? > > Thank you in advance, > Amy > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 3 Date: Sun, 12 Dec 2010 21:54:59 +0000 From: Amy de Buitl?ir <a...@nualeargais.ie> Subject: Re: [Haskell-beginners] If I only had a brain To: aditya siram <aditya.si...@gmail.com> Cc: beginners <beginners@haskell.org> Message-ID: <aanlktik2rs6bmwc=vg1y7k3mjgbuj-fgiujgbpsky...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On 12 December 2010 20:53, aditya siram <aditya.si...@gmail.com> wrote: > Does this help? I don't know what Neuron is so I've made it an Int to > get the code to compile. Yes, thank you! That solves the problem. ------------------------------ Message: 4 Date: Sun, 12 Dec 2010 22:18:59 +0000 From: Amy de Buitl?ir <a...@nualeargais.ie> Subject: Re: [Haskell-beginners] If I only had a brain To: aditya siram <aditya.si...@gmail.com> Cc: beginners <beginners@haskell.org> Message-ID: <aanlktinccmmyv1t52zc+5zspowoo88lizk50matg7...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 For anyone who might read this thread later, I did have to enable both RankNTypes and FlexibleContexts. On 12 December 2010 21:54, Amy de Buitl?ir <a...@nualeargais.ie> wrote: > On 12 December 2010 20:53, aditya siram <aditya.si...@gmail.com> wrote: >> Does this help? I don't know what Neuron is so I've made it an Int to >> get the code to compile. > > Yes, thank you! That solves the problem. > ------------------------------ Message: 5 Date: Sun, 12 Dec 2010 15:09:44 -0800 From: Russ Abbott <russ.abb...@gmail.com> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 30, Issue 17 To: beginners@haskell.org Message-ID: <aanlktin2rlrqop0rou851ljr9ohfhuryrxsl6e5o9...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Is there no way to make the class approach (or something like it) work? That's how I would do it in Java--define the component as an interface as far as the structure is concerned and then define the component itself to implement the interface. * -- Russ* On Sun, Dec 12, 2010 at 3:00 AM, <beginners-requ...@haskell.org> wrote: > Send Beginners mailing list submissions to > beginners@haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-requ...@haskell.org > > You can reach the person managing the list at > beginners-ow...@haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Re: Linking modules (Brent Yorgey) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 11 Dec 2010 15:37:23 -0500 > From: Brent Yorgey <byor...@seas.upenn.edu> > Subject: Re: [Haskell-beginners] Linking modules > To: beginners@haskell.org > Message-ID: <20101211203723.gb9...@seas.upenn.edu> > Content-Type: text/plain; charset=iso-8859-1 > > On Sat, Dec 11, 2010 at 08:56:23PM +0100, Chadda? Fouch? wrote: > > On Sat, Dec 11, 2010 at 7:37 PM, Russ Abbott <russ.abb...@gmail.com> > wrote: > > > I have two modules Structure and Component. ?Module Structure defines > > > ?? ? data Structure = Component ... > > > Module Component defines > > > ?? ?data Component = ... > > > I would like Structure to import Component. ?But Component > > > includes?functions?that take a Structure as an argument. So I have (or > would > > > like) something like this organization. > > > > > > [snip] > > > > > > The functions in Component are really very Component related and should > not > > > be moved to Structure. So how can I set up this circular relationship? > > > > GHC allows you to compile mutually recursive modules, see > > > http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion > > for how to do it. > > Yes, this is possible, but it has always seemed sort of fragile and > ugly to me. Another suggestion is to put the definitions of the > Structure and Component data types into a separate module called > Types, and then import Types into both the Structure module (which > defines functions over Structures) and the Component module (which > defines functions over Components). Then no circularity is needed. > > -Brent > > > > ------------------------------ > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > End of Beginners Digest, Vol 30, Issue 17 > ***************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20101212/dc260cfc/attachment-0001.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 30, Issue 18 *****************************************