Re: Simple monads

2003-06-30 Thread Christian Maeder
The portable parts of Control.Monad.State (that are sufficient for most cases) should be in an extra module (maybe called Control.Monad.StateTypes). In addition further non-overloaded names for put, get, gets and modify would be needed (maybe putState, getState, etc.) I fear, this would complicate

Re: Simple monads

2003-06-27 Thread Graham Klyne
At a casual glance, your Labeller looks to me like a state transformer monad. I've found that the State transformer monad in the hierarchical libraries can be useful for this kind of thing; the following example is part of a larger program, so it can't be run in isolation, but I hope it shows so

Re: Simple monads

2003-06-27 Thread Wolfgang Jeltsch
On Thursday, 2003-06-26, 23:57, CEST, Derek Elkins wrote: > [...] > > not deeply understanding the use of Haskell extensions in the State > > source, > > I'm assuming Control.Monad.State's source in which case -no- extensions are > used for -State- (well, at least I don't see any quickly glancing)

Re: Simple monads

2003-06-27 Thread Wolfgang Jeltsch
On Friday, 2003-06-27, 12:55, CEST, Christian Maeder wrote: > [...] > The portable parts of Control.Monad.State (that are sufficient for most > cases) should be in an extra module (maybe called Control.Monad.StateTypes). > In addition further non-overloaded names for put, get, gets and modify woul

Re: Simple monads

2003-06-27 Thread Christian Maeder
The previous "newtype Labeller a = Labeller (Int -> (Int, a))" (the result tuple is reversed within Control.Monad.State) would simply become (untested): newtype Labeller a = State Int a newLabel = do { n <- get; put (n + 1); return (Label n) } runLabeller l = execState l minBound it must be "e

Re: Simple monads

2003-06-27 Thread Christian Maeder
not deeply understanding the use of Haskell extensions in the State source, I'm assuming Control.Monad.State's source in which case -no- extensions are used for -State- (well, at least I don't see any quickly glancing). Extensions are used for the -MonadState class-. The portable parts of Con

Re: Simple monads

2003-06-26 Thread Derek Elkins
On Thu, 26 Jun 2003 14:40:51 -0400 (EDT) Mark Carroll <[EMAIL PROTECTED]> wrote: > Not really seeing why Unique is in the IO monad, What Unique? The one in the GHC source? If so, it seems that it's so you can create multiple unique supplies that don't overlap. Since the unique supply isn't a m

RE: Simple monads

2003-06-26 Thread Hal Daume
> (a) People could point out to me where I'm still confused, as > revealed by > my code. Is it needlessly complicated? looks pretty reasonable to me :) as to why Unique is in the IO monad is probabyl because if it were in any other monad, you could start the monad twice and thus get a repeat of

Simple monads

2003-06-26 Thread Mark Carroll
Not really seeing why Unique is in the IO monad, not deeply understanding the use of Haskell extensions in the State source, and wanting to try to learn a bit more about monads, I thought I'd try to write my own monad for the first time: something for producing a series of unique labels. This is ho