Re: findall resulting in strange message

From: Michael Hanus <mh_at_informatik.uni-kiel.de>
Date: Fri, 19 Apr 2013 14:21:40 +0200

On 04/19/2013 12:34 PM, Wolfgang Jeltsch wrote:
> I have a problem with using KiCS2. I have a source file that contains
> the following code:
>
>> sublist :: [a] -> [a]
>> sublist (pre ++ sub ++ post) = sub
>
> Now I load this into KiCS2 and enter the expression
>
> findall (\sub -> sub =:= sublist "Hallo!")
>
> at the prompt. KiCS2 answers with the message
>
> Main: external_ndho_C_try .
>
> What does this mean? Does this indicate a bug?

The error message is not good and should be improved.
Actually, the primitive encapsulation operator "try"
which is used in the standard prelude to implement
"findall" is not implemented in KiCS2.

Since appropriate definitions of search operators
is an ongoing topic for discussion (since the "naive"
inclusion of findall in the first version of Curry),
KiCS2 supports two more appropriate alternatives
to encapsulate non-deterministic computations:

1. Strong encapsulation: This means that all potential
    non-determinism is encapsulated. Since this might
    result in dependencies on the evaluation strategy
    (if non-deterministic computations are defined "outside"
    and passed "inside" an encapsulation operator), this kind
    of encapsulation is only available as I/O operations.
    For instance, the library AllSolutions provides

      getAllSolutions :: (a -> Success) -> IO [a]

    so that you can compute all your values by

      getAllSolutions (\sub -> sub =:= sublist "Hallo!") >>= print

    There is also the library SearchTree which provides
    programmable search strategies (depth-first, breadth-first,
    iterative deepening).

2. Weak encapsulation: This means that only the non-determinism
    defined inside an encapsulation operator is encapsulated.
    Since this is independent on the evaluation strategy,
    these concept can be also used independent of the I/O monad.
    Conceptually, these operators are offered as "set functions"
    which compute the set of all results but do not encapsulate
    non-determinism in the actual arguments. KiCS2 provides this
    functionality by the library SetFunctions. For instance, you
    can compute the set of all your results by

      (set1 sublist "Hallo!")

    Since the result is a set, you can only map or fold the results
    (see operations in the library SetFunctions) or transform them
    into a list by sorting them (of course, this works only for
    finite search spaces).

I hope this explanation helps. If you need more infos or pointers
to the literature, please let me know.

Best regards,

Michael

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Fr Apr 19 2013 - 14:40:02 CEST

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