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. Installing Haskell on a Mac (Torsten Otto) 2. Re: Installing Haskell on a Mac (Antoine Latter) 3. State monad (Britt Anderson) 4. Re: State monad (Mihai Maruseac) 5. Re: State monad (Mihai Maruseac) 6. Re: State monad (Britt Anderson) 7. Re: State monad (Ozgur Akgun) 8. Monad Transformer Type Signatures (Britt Anderson) 9. Re: Monad Transformer Type Signatures (Brent Yorgey) ---------------------------------------------------------------------- Message: 1 Date: Mon, 14 Feb 2011 15:28:43 +0100 From: Torsten Otto <t-otto-n...@gmx.de> Subject: [Haskell-beginners] Installing Haskell on a Mac To: beginners <beginners@haskell.org> Message-ID: <92f44889-644a-468e-80a1-533cdc763...@gmx.de> Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Hi! Two students in my class tried to install Haskell on their private MacBooks (one Leopard, one SnowLeopard). We used the package at http://hackage.haskell.org/platform/mac.html . Neither of them got to install it as the button "Install" is greyed and not clickable. What is the best way to install GHC on a current Mac? It would not necessarily have to be the latest greatest. Regards, Torsten ------------------------------ Message: 2 Date: Mon, 14 Feb 2011 09:28:25 -0600 From: Antoine Latter <aslat...@gmail.com> Subject: Re: [Haskell-beginners] Installing Haskell on a Mac To: Torsten Otto <t-otto-n...@gmx.de> Cc: beginners <beginners@haskell.org> Message-ID: <AANLkTi=YaiPtonGN=jy2sduhz_dhzopqr9jvnrh-v...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Mon, Feb 14, 2011 at 8:28 AM, Torsten Otto <t-otto-n...@gmx.de> wrote: > Hi! > > Two students in my class tried to install Haskell on their private MacBooks > (one Leopard, one SnowLeopard). We used the package at > http://hackage.haskell.org/platform/mac.html. ?Neither of them got to > install it as the button "Install" is greyed and not clickable. > > What is the best way to install GHC on a current Mac? It would not > necessarily have to be the latest greatest. > The most common cause of this error is not having Xcode installed. It should be on one of the discs that came with the Mac, but it is also available from Apple if you make a (free) login to their dev site: http://developer.apple.com/technologies/xcode.html Antoine > Regards, > Torsten > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 3 Date: Mon, 14 Feb 2011 13:11:19 -0500 From: Britt Anderson <britt.uwater...@gmail.com> Subject: [Haskell-beginners] State monad To: beginners@haskell.org Message-ID: <aanlktimw-2maaiebbg66fy_mr0xed1tu3cmvpfnjq...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Many of the tutorials on the state monad seem to suggest that you can use State as a data constructor, but I can't get this to work. E.g. in ghci after :m Control.Monad.State I can let f = (\x -> (x,x)) let y = state f but if I, let z = State f I get an error message: Not in scope: data constructor `State'. Can someone please explain? Thanks, Britt -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110214/96ec32dd/attachment-0001.htm> ------------------------------ Message: 4 Date: Mon, 14 Feb 2011 20:18:16 +0200 From: Mihai Maruseac <mihai.marus...@gmail.com> Subject: Re: [Haskell-beginners] State monad To: Britt Anderson <britt.uwater...@gmail.com> Cc: beginners@haskell.org Message-ID: <aanlktinxyhzbe7zy-r1hpy_t4jefa1yjlkf0+aa6r...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 14, 2011 at 8:11 PM, Britt Anderson <britt.uwater...@gmail.com> wrote: > Many of the tutorials on the state monad seem to suggest that you can use > State as a data constructor, but I can't get this to work. E.g. in ghci > after :m Control.Monad.State I can > > let f = (\x -> (x,x)) > let y = state f > > but if I, > > let z = State f > > I get an error message: Not in scope: data constructor `State'. > > Can someone please explain? > > Thanks, Britt > > GHCi doesn't load all Haskell modules by default. It only loads Prelude. You'll have to load them by hand. Use :m +Control.Monad.State -- Mihai ------------------------------ Message: 5 Date: Mon, 14 Feb 2011 20:19:13 +0200 From: Mihai Maruseac <mihai.marus...@gmail.com> Subject: Re: [Haskell-beginners] State monad To: Britt Anderson <britt.uwater...@gmail.com> Cc: beginners@haskell.org Message-ID: <aanlktikukccx09t+buntrcon8dmc5dh6z-qsp0kok...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 14, 2011 at 8:18 PM, Mihai Maruseac <mihai.marus...@gmail.com> wrote: > On Mon, Feb 14, 2011 at 8:11 PM, Britt Anderson > <britt.uwater...@gmail.com> wrote: >> Many of the tutorials on the state monad seem to suggest that you can use >> State as a data constructor, but I can't get this to work. E.g. in ghci >> after :m Control.Monad.State I can >> >> let f = (\x -> (x,x)) >> let y = state f >> >> but if I, >> >> let z = State f >> >> I get an error message: Not in scope: data constructor `State'. >> >> Can someone please explain? >> >> Thanks, Britt >> >> > > GHCi doesn't load all Haskell modules by default. It only loads > Prelude. You'll have to load them by hand. Use > > :m +Control.Monad.State > Also, see if you have the mtl library installed (or Transformers). -- Mihai ------------------------------ Message: 6 Date: Mon, 14 Feb 2011 13:23:43 -0500 From: Britt Anderson <britt.uwater...@gmail.com> Subject: Re: [Haskell-beginners] State monad To: beginners@haskell.org Message-ID: <aanlktimpt255extafh2ccez461wr6lt-wzxszemjs...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Actually, I can load the module and I have mtl. I just don't understand why I can use State as a data constructor, but the inverse of runState, i.e. state works just fine. Has this library/package been reconfigured from when most people were writing tutorials? On Mon, Feb 14, 2011 at 1:19 PM, Mihai Maruseac <mihai.marus...@gmail.com>wrote: > On Mon, Feb 14, 2011 at 8:18 PM, Mihai Maruseac > <mihai.marus...@gmail.com> wrote: > > On Mon, Feb 14, 2011 at 8:11 PM, Britt Anderson > > <britt.uwater...@gmail.com> wrote: > >> Many of the tutorials on the state monad seem to suggest that you can > use > >> State as a data constructor, but I can't get this to work. E.g. in ghci > >> after :m Control.Monad.State I can > >> > >> let f = (\x -> (x,x)) > >> let y = state f > >> > >> but if I, > >> > >> let z = State f > >> > >> I get an error message: Not in scope: data constructor `State'. > >> > >> Can someone please explain? > >> > >> Thanks, Britt > >> > >> > > > > GHCi doesn't load all Haskell modules by default. It only loads > > Prelude. You'll have to load them by hand. Use > > > > :m +Control.Monad.State > > > > Also, see if you have the mtl library installed (or Transformers). > > -- > Mihai > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110214/914c044c/attachment-0001.htm> ------------------------------ Message: 7 Date: Mon, 14 Feb 2011 18:44:32 +0000 From: Ozgur Akgun <ozgurak...@gmail.com> Subject: Re: [Haskell-beginners] State monad To: Britt Anderson <britt.uwater...@gmail.com> Cc: beginners@haskell.org Message-ID: <AANLkTi=qo1frtzdkgfaxyyrwy57xsdyfxqcs5xbkt...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" In the latest version of mtl, there is no State data constructor. http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/Control-Monad-State-Lazy.html#g:2 State<http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#t:State>is defined to be a type alias to the application of Identity monad to the StateT monad transformer. As you've already discovered, you need to use state<http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#v:state> instead. HTH, Ozgur On 14 February 2011 18:11, Britt Anderson <britt.uwater...@gmail.com> wrote: > Many of the tutorials on the state monad seem to suggest that you can use > State as a data constructor, but I can't get this to work. E.g. in ghci > after :m Control.Monad.State I can > > let f = (\x -> (x,x)) > let y = state f > > but if I, > > let z = State f > > I get an error message: Not in scope: data constructor `State'. > > Can someone please explain? > > Thanks, Britt > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20110214/59926f80/attachment-0001.htm> ------------------------------ Message: 8 Date: Mon, 14 Feb 2011 14:10:13 -0500 From: Britt Anderson <britt.uwater...@gmail.com> Subject: [Haskell-beginners] Monad Transformer Type Signatures To: beginners@haskell.org Message-ID: <AANLkTi=ivhOyQCE2Pj5wh_c=lg4c+pd71rwpdvo+s...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 I am looking at code from a tutorial that has the following type signature for a function: getScreen :: MonadReader AppConfig m => m Surface AppConfig is a data structure that was defined previously. My question is how am I to interpret this type signature? Is it any m belonging to the MonadReader AppConfig class? or any AppConfig m belonging to the MonadReader class? Since I can't see any instance of the MonadReader Class being defined for MonadReader AppConfig I am puzzled. I would appreciate some clarification or a pointer to a prior discussion of this issue. I have tried to look on my own. Thank you. ------------------------------ Message: 9 Date: Mon, 14 Feb 2011 14:24:18 -0500 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] Monad Transformer Type Signatures To: beginners@haskell.org Message-ID: <20110214192418.ga29...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Mon, Feb 14, 2011 at 02:10:13PM -0500, Britt Anderson wrote: > I am looking at code from a tutorial that has the following type > signature for a function: > > getScreen :: MonadReader AppConfig m => m Surface > > AppConfig is a data structure that was defined previously. My question > is how am I to interpret this type signature? Is it any m belonging to > the MonadReader AppConfig class? Yes. And there will be an instance for MonadReader AppConfig m exactly when m carries around an implicit "read-only" AppConfig value, available for querying with the 'ask' and 'asks' functions. > Since I can't see any instance of the MonadReader > Class being defined for MonadReader AppConfig I am puzzled. Typically what you will see is some concrete monad later being defined in terms of ReaderT AppConfig, which will automatically give it an appropriate MonadReader instance, allowing users of the monad to query the AppConfig. > I would appreciate some clarification or a pointer to a prior > discussion of this issue. I have tried to look on my own. I recommend reading Cale Gibbard's article "How to use monad transformers"... except at the moment I can't seem to find it anywhere. =( -Brent ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 32, Issue 30 *****************************************