Re: Smap: Collecting small programs

From: Michael Hanus <>
Date: Thu, 30 Oct 2014 17:58:54 +0100

Hi David,

this is only a partial answer to all the issues you pointed out.

You wrote:
> 2. The operator precedences don’t have enough granularity - I wanted a
> precedence of 4.5 for difference lists

I agree, but this is inherited from Haskell. At some early point we
decided for compatibility with Haskell instead of creating a new

> 3/4. There are issues relating to free variables and unification models
> that prevent translation from Prolog.
> ...

In principle, any *logic program* can be translated to Curry
in a straightforward manner. However, for Prolog with all its
non-logic features, it is different.

> Even adding in ensureNotFree doesn’t help as all disjunctions can suspend…
> I do have a working (sicstus/swipl) Prolog version of this!

Just a comment: ensureNotFree only suspends computations but can't
be used as a case distinction. Hence, you can't do a case distinction
on difference lists (similar to logic programming) so that difference
lists should only be used for producing results. For instance,
the reverse operation takes a standard list and produces a difference

revD :: [a] -> DList a
revD [] = (m#m) where m free
revD (x:xs) = appD (revD xs) (x:m # m) where m free

with difference list concatenation defined by

appD (a#b) (b#n) = (a#n)

In a similar way, you can also define quicksort with difference lists.
I added these examples, of course, to Smap:

Best regards,

curry mailing list
Received on Do Okt 30 2014 - 17:59:58 CET

This archive was generated by hypermail 2.3.0 : Mo Dez 04 2023 - 07:15:13 CET