[Haskell-cafe] Monads as control structures?

2005-10-27 Thread Creighton Hogg
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

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Björn Bringert
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

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread ChrisK
Try this: This line is before the loop sequence_ $ replicate 10 $ do line 1 line 2 ... last line This line is after the loop Now you can use shorthand via loopN n block = sequence_ $ replicate n block So that you can write: This line is before the loop loopN 10 $ do line 1 line 2

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Robert Dockins
On Oct 27, 2005, at 11:54 AM, 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

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Bryn Keller
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

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Creighton Hogg
On Thu, 27 Oct 2005, Creighton Hogg wrote: On Thu, 27 Oct 2005, Robert Dockins wrote: On Oct 27, 2005, at 11:54 AM, 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

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Bulat Ziganshin
Hello Creighton, Thursday, October 27, 2005, 7:54:22 PM, you wrote: CH Haskell seems to me to be a very powerful language, and it CH looks like it should be possible to define control CH structures such as for loops using monads. it's my own lib: -- |Conditional execution whenM cond action =