[Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Mauricio
Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every "step"? do-it-yourself? you can start from reader definition and add what you need. you just need to make "initial state" consisting from state itsel

[Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Mauricio
Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every "step"? >>> > It doesn't quite make sense, because one "step" isn't well defined. > How many "steps" is "return (f x)" ? how

[Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Achim Schneider
Mauricio <[EMAIL PROTECTED]> wrote: > [...] > Are you sure you don't want to use monad transformers? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibite

[Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Maurí­cio
[...] Are you sure you don't want to use monad transformers? No. Do you have a sugestion on how could I do it in this situation? Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: Monad.Reader with updates

2008-11-07 Thread Mauricio
> Hi Mauricio. What you want actually already exists in QuickCheck as > the "Gen" monad. > > newtype Gen a > = Gen (Int -> StdGen -> a) > > instance Monad Gen where > return a= Gen (\n r -> a) > Gen m >>= k = > Gen (\n r0 -> let (r1,r2) = split r0 > Gen m' = k

[Haskell-cafe] Re: Monad.Reader with updates

2008-11-07 Thread Achim Schneider
Maurcio <[EMAIL PROTECTED]> wrote: > > > >> [...] > >> > > Are you sure you don't want to use monad transformers? > > > > No. Do you have a sugestion on how could I do > it in this situation? > Not really, mainly because if monad transformers don't confuse you you should double-check if yo

Re: [Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Bulat Ziganshin
Hello Mauricio, Thursday, November 6, 2008, 2:52:16 PM, you wrote: > that. But I wanted to know if there's already the > "right way to do it" instead of my "newbie way to > do it" :) "All about monads" doesn't mention it, at least :) -- Best regards, Bulatmailto:[

Re: [Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Jules Bean
Mauricio wrote: Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every "step"? do-it-yourself? you can start from reader definition and add what you need. you just need to make "initial state" consisting

Re: [Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Jules Bean
Mauricio wrote: The problem is that I need 'a' or 'b' above to sometimes also change the environment. I think with this method I could not get that. I no longer understand what you want. I thought you wanted an environment which automatically changed every "step". I showed you how you can

Re: [Haskell-cafe] Re: Monad.Reader with updates

2008-11-06 Thread Ryan Ingram
Hi Mauricio. What you want actually already exists in QuickCheck as the "Gen" monad. >From >http://hackage.haskell.org/packages/archive/QuickCheck/1.1.0.0/doc/html/src/Test-QuickCheck.html#Gen newtype Gen a = Gen (Int -> StdGen -> a) instance Monad Gen where return a= Gen (\n r -> a)

Re: [Haskell-cafe] Re: Monad.Reader with updates

2008-11-07 Thread Brent Yorgey
On Fri, Nov 07, 2008 at 10:41:01AM +0100, Achim Schneider wrote: > > But then, you either want a ReaderT r State s or StateT s Reader r, > depending on how you want to write your code... the main thing that > confuses me right now is that nesting order doesn't seem to matter that > much in this ca