Re: set functions and weak encapsulation

From: Sebastian Fischer <>
Date: Mon, 12 Mar 2012 09:57:38 +0100

Hi Wolfgang,

On Mon, Mar 12, 2012 at 9:39 AM, Wolfgang Lux <> wrote:
> An interesting idea -- but a values function with weak encapsulation will not work as you expected. The result of values (0 ? 1) would be {0} ? {1} rather than {0,1}.

I agree that defining 'values' using the weak encapsulating 'findall'
in MCC like this

    values x = findall (\y -> x =:= y)

will behave as you described. But wouldn't it be possible to add a
*primitive* operation 'values' such that

    values (0?1) = {0,1}


    let x = 0?1 in values x = {0} ? {1}


> PS I was surprised (should I say astonished) about the interface of PAKCS' SetFunctions module. It is apparently using strong encapsulation for a pure function: set0 :: a -> Values a (and I would assume the other setN function are using strong encapsulation for their first argument as well). That means that code using these function is susceptible to the known problems of strong encapsulation with evaluation order.

The 'Values' type is deliberately abstract and does not allow to
observe the order of results. Other problems of strong encapsulation
are avoided by the restricted form of encapsulation that set functions
provide, as far as I can tell.

Or can you give an example, where evaluation order determines the
result of a program using set functions (as implemented in PAKCS)?


curry mailing list
Received on Mo Mär 12 2012 - 11:48:07 CET

This archive was generated by hypermail 2.3.0 : Di Sep 29 2020 - 07:15:03 CEST