>Suppose Sven implements his `len' function as above, and furthermore
>implements a library which depends on this function being hyperstrict.
>Suppose next that I implement an instance of `==' that returns `True' without
>evaluating the arguments, and then finally suppose a third programmer called
>say Joe comes along and uses my type with Sven's library.  If it breaks, who
>is to blame?

I think the cleanest solution is to add a method "hseq" to the Eval class,
which is similar to seq but evaluates its first argument hyperstrictly
before returning its second. Then Sven can write
>    len :: Eq a => [a] -> Int
>    len [] = 0
>    len (x:xs) = x `hseq` (1 + len xs)

We did this in "Data Field Haskell" - a dialect of Haskell for
collection-oriented programming which we have designed and made a prototype
implementation of - where we happened to need this functionality. (Those of
you who are interested can have a look at
http://www.it.kth.se/labs/paradis/dfh/. I plan to make a "public release" of
of the system and announce it here, but there are still some problems with
the installation scripts so I have put the release on hold until we have
sorted these problems out. For now, download at your own risk.... :-)

Björn Lisper

Reply via email to