[Haskell-cafe] How to write elegant Haskell programms?
rjmh at cs.chalmers.se
Tue Jan 30 09:55:46 EST 2007
>I think that whole "program flow" thing is something you get used to. In
>>true, pure functional programming (i.e. Haskell) "program flow" is a
>>meaningless term, basically. Haskell is a declarative language, not an
>>imperative one. You have to learn to give up that control and trust the
>>runtime to Do The Right Thing. (In this regard it's similar to logic
>I think it's important/useful to point out that "program flow" in a pure
>functional language is really a matter of data dependency. The compiler is
>only free to arbitrarily order computations if there are no data
>dependencies. Furthermore, monads are not special in any way (they are after
>all just a useful set of combinators; e.g.
>they only wind up sequencing computations because they set up a data
>dependency between the two arguments of the bind operator.
And actually they don't even do that, always. A useful example in
practice: then Gen monad in QuickCheck does *not* necessarily set up any
data dependencies, so do in the Gen monad does not force sequencing. The
fact that it's non-strict is what enables us to generate infinite random
data-structures with it.
More information about the Haskell-Cafe