[Haskell-cafe] Monads as control structures?
Björn Bringert
bringert at cs.chalmers.se
Thu Oct 27 12:07:17 EDT 2005
Creighton Hogg wrote:
> Hi,
> so I'm a newbie getting used to Haskell. I'm writing some
> simple things like genetic algorithms in it for practice,
> and I keep coming across something that really bugs me:
> are there any standard libraries that allow you to
> do imperative style for or while loops using monads to keep
> track of state?
>
> I know there's things like "until", but honestly that's not
> quite what I'm looking for.
>
> I just think there should be a simple way to say "execute
> this block of code 10 times" without having to wrap it up in
> recursion.
>
> Haskell seems to me to be a very powerful language, and it
> looks like it should be possible to define control
> structures such as for loops using monads.
Could Control.Monad.replicateM or Control.Monad.replicateM_ be what you
are looking for?
/Björn
More information about the Haskell-Cafe
mailing list