[clean-list] undefined strictness

Bernard James POPE bjpop@students.cs.mu.OZ.AU
Wed, 14 Jul 2004 16:49:59 +1000


On Wed, Jul 14, 2004 at 08:08:37AM +0200, Erik Zuurbier wrote:
> Hi all,
> 
> In the middle of a Clean 2.1 program I write (in the Windows IDE) a function
> myfun that is not used anywhere else:
> 
> myfun :: Int Real -> String
> myfun x y = undef
> 
> Then when I call the compiler and watch the Types window, I see:
> 
> myfun :: !Int !Real -> {#Char}
> 
> My question is: how can it derive the strictness? I expected the arguments
> would be considered non-strict.

I'm not a Clean expert so please keep that in mind. However, the usual
definition of a strict function is:

   A function f is strict if and only if:

      f _|_ = _|_

Where _|_ is bottom (divergence). You can easily extend this to
higher arities.

It appears that myfun always diverges, no matter what arguments
you give it --- I am assuming that undef is some kind of divergent
thing like:

   undef = undef

Thus myfun is by definition strict in both of its arguments.

I don't know what the type {#Char} means in Clean so I won't comment on
that (is it an unboxed list?). Perhaps String is a synonym for that.

You can also take an operational point of view. The strict annotation
says to the compiler that it can go ahead and evaluate the arguments
of an application _before_ the body. In this case it won't matter if
the evaluation of an argument diverges because the body is going to
diverge anyway.

I hope this is accurate according to the Clean semantics - as I said
I'm no expert on the matter.

Cheers,
Bernie.