- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Wolfgang Lux <wlux_at_uni-muenster.de>

Date: Mon, 12 Mar 2012 09:39:22 +0100

Sebastian Fischer wrote:

*> while preparing a talk about encapsulated search, it occurred to me
*

*> that set functions are a special case of weak encapsulation, not
*

*> exposing the encapsulation primitive.
*

*>
*

*> Assuming a weak encapsulation function
*

*>
*

*> values :: a -> {a} -- set of values of type a
*

*>
*

*> we can implement set functions as follows. For
*

*>
*

*> f x = x + (0?1)
*

*>
*

*> we can implement
*

*>
*

*> f_set x = values (f x)
*

*>
*

*> which will satisfy
*

*>
*

*> f_set (10?20) = {10,11} ? {20,21}
*

*>
*

*> I have not thought about set functions like this before. Have you?
*

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}.

*> This suggests that set functions can be added to MCC easily:
*

*>
*

*> f_set x = findall (\y -> y =:= f x)
*

*>
*

*> already behaves like 'set_f' above in MCC because, there, findall
*

*> implements weak encapsulation. All that remains is using an abstract
*

*> datatype to hide the order of list element, like the Values type used
*

*> in PAKCS:
*

*>
*

*> http://www.informatik.uni-kiel.de/~pakcs/lib/CDOC/SetFunctions.html#Values
*

*>
*

*> Unlike PAKCS's implementation, the MCC implementation would not be
*

*> restricted by evaluating arguments call-by(-deep)-value, so
*

*>
*

*> const_set (0?1) failed = {0} ? {1}
*

*>
*

*> would work in MCC while it, currently, does not work in PAKCS.
*

And FWIW, it can also handle non-ground arguments :-)

member (x:xs) = x ? member xs

member_set xs = findall (\x -> x =:= member xs)

let A,B free in member_set [A,B]

Now, what would be nice would be some nice syntax (sic!) to automatically derive member functions for any function defined in Curry. Any suggestions?

Cheers

Wolfgang

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.

_______________________________________________

curry mailing list

curry_at_lists.RWTH-Aachen.DE

http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry

Received on Mo Mär 12 2012 - 11:47:10 CET

Date: Mon, 12 Mar 2012 09:39:22 +0100

Sebastian Fischer 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}.

And FWIW, it can also handle non-ground arguments :-)

member (x:xs) = x ? member xs

member_set xs = findall (\x -> x =:= member xs)

let A,B free in member_set [A,B]

Now, what would be nice would be some nice syntax (sic!) to automatically derive member functions for any function defined in Curry. Any suggestions?

Cheers

Wolfgang

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.

_______________________________________________

curry mailing list

curry_at_lists.RWTH-Aachen.DE

http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry

Received on Mo Mär 12 2012 - 11:47:10 CET

*
This archive was generated by hypermail 2.3.0
: Mo Okt 26 2020 - 07:15:05 CET
*