[Haskell-cafe] Delaling with State StateT and IO in the same function

Alfonso Acosta alfonso.acosta at gmail.com
Mon Feb 26 18:26:06 EST 2007


On 2/27/07, Kirsten Chevalier <catamorphism at gmail.com> wrote:

> I may be missing something, but why are you using both State and
> StateT? Maybe I don't understand your code, but it seems like you
> could be using StateT everywhere you're currently using State.

Well, as far as I know using "StateT s IO a" for the input functions
would force the state and value of their monad to stay within IO. That
restriction dissapears by using barely "State s a"

> Also, your type signatures would be easier to read if you defined a
> type synonym for your instantiation of StateT, e.g.:
>
> type AlfonsoM s = StateT s IO ()
>
> and then everywhere you write (StateT s IO ()) now, you could write
> (AlfonsoM s) instead.

Thanks for the suggestion, I'll make use of it :)


More information about the Haskell-Cafe mailing list