Re: from static typing to runtime constraints

From: Bernd Brassel <bbr_at_informatik.uni-kiel.de>
Date: Mon, 11 Dec 2006 09:44:23 +0100

Sergio Antoy wrote:
> Sebastian,
>
> Below is another technique, in addition to Bernd's, to simulate
> the run (I call it need) time choice semantics. Probably, it is
> less efficient. Runs under pakcs.
>
> Cheers,
> Sergio
>
>
> getAllValues x = findall (=:= x)
> chooseValue (u:v) = u ? chooseValue v
>
> data Color = Red | Green
> Color = Red ? Green
> data Tree a = Leaf | Node a (Tree a) (Tree a)
> Tree a = Leaf ? Node (chooseValue b) (Tree a) (Tree a)
> where b = getAllValues a
>
> test = Node Red (Node Green Leaf Leaf) Leaf =:= Tree Color
>

This technique can turn bad, however, in some cases. The reason is that
the definition (runTimeChoice = chooseValue . getAllValues) has to
compute normal forms to be correct. Thus, if you either write

Tree a = Leaf ?
         Node (runTimeChoice b)
              (runTimeChoice (Tree a))
              (runTimeChoice (Tree a))

or extend the Color type by a recursive constructor:

data Color = Mix Color Color | Read | Green

you get infinite search branches.

Also, any of the techniques relies on breadth first search, and in
consequence pakcs is not the right environment for this.

Greetings
Bernd

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Dez 11 2006 - 10:15:55 CET

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