Lennart Augustsson wrote:
| > funWrapper y = runST computation
| > where
| > computation =
| > do var <- newSTRef []
| > let fun x = .. var .. x ..
| > fun y
|
| Where is the polymorphism?
You're right! This was indeed a bad example. A better
example would of course be part of a real program, and I
abstracted away too much in this general scheme.
It should be: Suppose I have a polymorphic function fun, and
some program which uses fun several times on different types
(not all that uncommon):
fun x = .. x ..
program = .. fun a .. fun b ..
Now everything suddenly depends on a state "var". So the
program becomes:
program = runST
(do var <- newSTRef []
let fun x = .. var .. x ..
.. fun a .. fun b ..)
The problem with all examples is that it is always
expressible without it. I could have said:
fun var x = .. var .. x ..
program = runST
(do var <- newSTRef []
.. fun var a .. fun var b ..)
But that is not the point. I just went through my code and
looked at how many definitions in do-notation actually were
polymorphic.
/Koen.
--
Koen Claessen http://www.cs.chalmers.se/~koen
phone:+46-31-772 5424 mailto:[EMAIL PROTECTED]
-----------------------------------------------------
Chalmers University of Technology, Gothenburg, Sweden