On Fri, May 23, 2008 at 2:20 PM, Thomas Hartman <[EMAIL PROTECTED]> wrote:

> > The big benefit I got from using the State Monad was that I was able to
> reorder the functions > by just copy/pasting the function name from one
> place to another.
>
> I don't understand... why do you need state to do this? Couldn't you
> have a function pipeline using dots for composition like
>
>  .... (
>    ...
>    parseAttn .
>    parsePoBox .
>    ...
>    ) address ...
>
> and have the functions be equally switchable? (well, the first and
> last can't quite be copy pasted, but close enough.)
>
> Introducing state seems like a lot of trouble to me if the only one is
> easier reorderability of lines.
>

Agreed, in fact I started with a function pipeline and then switched to
using the State Monad. As the program was written months ago I don't
remember exactly why. Maybe I don't like to read backwards. ;-)

Funtions running in the state monad can call other functions with the same
`State s a` signature (and so on as deep as you want). You never have to
care about passing parameters and restarting a new pipeline. But of course
you can easily do without the State Monad. I don't think the State Monad
allows to do thing that you can't do with basic Haskell. It just makes code
more readable (in my opinion at least).

Olivier.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to