Re: [Haskell-cafe] Stacking StateTs

2009-02-23 Thread wren ng thornton
Luis O'Shea wrote: One way to do this is to stack two StateTs on top of m. Another way, what might be easier to reason about, is to crush those two layers together and use a tuple for the state: StateT s1 (StateT s2 m) a == StateT (s1,s2) m a Then the only thing you'll have to worry

Re: [Haskell-cafe] Stacking StateTs

2009-02-22 Thread Luis O'Shea
test3 :: MonadState Integer m = String - m String Good point. It's interesting that this allows the signature of test5b to become MonadState Integer m = m Integer (instead of (Monad m) = StateT Integer (StateT String m) Integer) which is more general, and (surprisingly to me) does not

Re: [Haskell-cafe] Stacking StateTs

2009-02-22 Thread David Menendez
On Sun, Feb 22, 2009 at 9:20 AM, Luis O'Shea los...@gmail.com wrote: test3 :: MonadState Integer m = String - m String Good point. It's interesting that this allows the signature of test5b to become MonadState Integer m = m Integer (instead of (Monad m) = StateT Integer (StateT String m)

Re: [Haskell-cafe] Stacking StateTs

2009-02-22 Thread Daniel Fischer
Am Sonntag, 22. Februar 2009 18:53 schrieb David Menendez: On Sun, Feb 22, 2009 at 9:20 AM, Luis O'Shea los...@gmail.com wrote: test3 :: MonadState Integer m = String - m String Good point. It's interesting that this allows the signature of test5b to become MonadState Integer m = m

Re: [Haskell-cafe] Stacking StateTs

2009-02-22 Thread Felipe Lessa
On Sun, Feb 22, 2009 at 3:17 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: test5b :: (Monad (StateT [Char] (StateT s m)), MonadState s (StateT s m), Num s, Monad m) = m s Doesn't 'Monad m' imply 'MonadState s (StateT s m)' which implies 'Monad

Re: [Haskell-cafe] Stacking StateTs

2009-02-22 Thread Daniel Fischer
Am Sonntag, 22. Februar 2009 19:29 schrieb Felipe Lessa: Did I make any mistakes? No, I did. I didn't read it properly, saw the MonadState s ... there and thought it was MonadState s m instead of MonadState s (StateT s m). Sorry, Daniel ___

[Haskell-cafe] Stacking StateTs

2009-02-21 Thread Luis O'Shea
I've been experimenting with the state monad and with StateT, and have some questions about how to combine one state with another. This email is literate Haskell tested on GHCi, version 6.10.1. Also, sigfpe's post on monad transformers (http://blog.sigfpe.com/2006/05/

Re: [Haskell-cafe] Stacking StateTs

2009-02-21 Thread David Menendez
On Sat, Feb 21, 2009 at 3:33 PM, Luis O'Shea los...@gmail.com wrote: I've been experimenting with the state monad and with StateT, and have some questions about how to combine one state with another. snip test3 :: Monad m = String - StateT Integer m String test3 s = do modify (+ 1) a -

Re: [Haskell-cafe] Stacking StateTs

2009-02-21 Thread Antoine Latter
On Sat, Feb 21, 2009 at 5:37 PM, David Menendez d...@zednenem.com wrote: PS. Here are two functions that I ended up not using in my examples, but which may come in handy when dealing with nested applications of StateT: curryStateT :: (Monad m) = StateT (s,t) m a - StateT s (StateT t m) a