Re: Proposal: change flexible/rigid default in Curry

From: Wolfgang Lux <wlux_at_uni-muenster.de>
Date: Mon, 02 Sep 2002 11:14:41 +0200

Hello Michael!

> after some discussion about programming in Curry with Sergio,
> we want to propose to change the flexible/rigid default in Curry.

after some discussion with Herbert, we do not object to this proposal.

While we loose the IMHO nice property, that it is easy to determine the
evaluation mode of a function by looking at its result type and replace
it by the quite obscure criterion of being an external function (BTW,
if_then_else is not an external function), I have to agree that the
advantages of the change outweigh this particular disadvantage.

However, I suggest a slight change in the proposal. IMHO there is no
reason to make IO functions flexible, as a non-deterministic IO
operation
immediately aborts the program. Therefore, I think functions with result
type IO should be rigid functions by default as well (and I see no
problem
that it becomes impossible to define a flexible IO function with the
proposed change).

BTW, there is another argument for making defined functions flexible in
general. It is quite easy to turn a flexible function into a rigid
function
but not vice versa. To this end I would suggest to complement the
proposal by adding the functions
seq :: a -> b -> b
($!) :: (a -> b) -> a -> b
from the Haskell Prelude to the Curry prelude.

The operational semantics of seq x y is that it evaluates x to head
normal
form and otherwise is equivalent to id y. Being an external function,
this primitive is a rigid function, and therefore can be used to make an
argument of a flexible function rigid.

The operator ($!) is defined by f $! x = x `seq` f x.

Regards
Wolfgang

--
Wolfgang Lux                              Phone: +49-251-83-38263
Institut fuer Wirtschaftinformatik          FAX: +49-251-83-38259
Universitaet Muenster                 Email: wlux_at_uni-muenster.de
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Sep 02 2002 - 11:15:26 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:06 CEST