[Haskell-cafe] Composing functions with runST
sethg at ropine.com
Wed Jan 3 12:15:00 EST 2007
David House wrote:
>> So I can't just tell someone who's just starting to learn Haskell that
>> "f $ g y" is equivalent to "f (g y)"; I have to say "those two are
>> *almost always* equivalent, but if you use $ and the compiler complains
>> about not being able to match the expected and the inferred type and a
>> type signature in the error message has the word 'forall', try rewriting
>> that expression without the $ and see if it compiles". Eeeww.
> Why would someone just starting to learn Haskell be using ST? The
> canonical tutorial structure is to start with the pure stuff and only
> introduce the (more complicated!) impure stuff (ST, IORefs, etc.) in
> an 'advanced techniques' or similar section.
I (and one other person on this list) ran into this issue when I was
trying to use takusen to make Haskell talk to a RDBMS. You obviously
need to learn advanced techniques to *implement* such a thing, but you
shouldn't need advanced knowledge to *use a library* that happens to use
higher-rank polymorphic types in its API.
There are many routes to fluency in a language, and not everybody is
suitable for the route of "here are the axioms underlying the language
and the simplest code that applies them; after you thoroughly understand
those, we'll show you how to make something practical". Some of us
prefer the route of "here are some examples of how to get practical
things done; after you're comfortable with them, we'll show you the
theory that underlies them". Actually, I suspect that *most* of us
prefer the second route. Set theory is closer to the theoretical
foundations of mathematics than arithmetic, but when elementary schools
tried teaching kids set theory, it didn't work out so well.
More information about the Haskell-Cafe