Re: prelude extension proposal

From: Michael Hanus <>
Date: Tue, 25 Oct 2005 16:10:39 +0200

Sergio Antoy wrote:
> Since magic is involved, why can't I make it a bit more magic and
> much easier to follow? So I learned to place the following in
> lect1.curry
> allValuesOf x = findall (x =:=)
> This makes a simpler lecture because I get the above questions
> by e-mail the next day after the students look at my code.

I think the presence and use of such an operation is also
risky and might lead later to a lot of confusion. For instance,
the discussion about a new handling of encapsulated search
started in our group when a student tried to write a very
smart program containing nested applications of findall
and the program didn't behave as expected. There we learned
that, although findall or allValuesOf could be nice operations,
their operational behavior is difficult to understand when they are
treated as standard operations. Therefore, we became convinced
that it should be placed in the I/O monad to avoid its use
in arbitrary expressions. In order to provide students
an easy way to see all solutions at once, you might put
into the prelude the definition

  printAllValues x = getAllValues e >>= print

> ... Another concern is that the
> semantics of something like allValuesOf is difficult to capture
> and its implementation should better be in the IO-monad. Ok, but
> since I can simply put my allValuesOf in my program, what am I
> saved from by not finding it in the prelude?

I think you can only put the definition of allValuesOf in your
program since the prelude still contains the (now questionable)
primitive "findall". If this will be omitted and replaced by
getAllValues, then the only way to define allValuesOf is by

  allValuesOf = unsafePerformIO . getAllValues

making it explicit that allValuesOf is unsafe...

Best regards,


curry mailing list
Received on Di Okt 25 2005 - 16:28:41 CEST

This archive was generated by hypermail 2.3.0 : Di Nov 28 2023 - 07:15:08 CET