Re: Curry-on to infinity

From: Sebastian Hanowski <sebastian_hanowski_at_gmx.de>
Date: Wed, 9 Dec 2015 07:41:22 +0100

On Mon, Dec 07, 2015 at 04:48:12PM +0100, Michael Hanus wrote:
> Hi,
>
> just a short comment. I think the reason why your example works
> is not due to the features of Curry but due to the unintended use
> of some features. The non-strict unification operator (=:<=)
> is intended to implement functional patterns, i.e., a rule like
>
> last (_++[x]) = x
>
> is transformed into
>
> last xs | _++[x] =:<= xs =x where x free
>
> in order to implement the intended semantics of functional patterns.
> As an invariant, the second argument is always a variable denoting
> some actual argument. Without this invariant, as in your fib example,
> I don't see some declarative meaning of this operator (at least,
> it has not be explored).

I see.

Then would this definition would be a little more acceptable?

        fibgen fib | head fib =:<= 1
                    & head (tail fib) =:<= 1
                    & tail (tail fib) =:<= zipWith (+) fib (tail fib) = fib

        fib = fibgen unknown

It just like it how this line

                    ...
                    & tail (tail fib) =:<= zipWith (+) fib (tail fib) = fib

makes so clear that to compute later parts it uses only earlier parts.

And the expression right hand side features only proper sub-parts of the
one on the left.
Looks pretty safe like being "structurally recursive" somehow ;)


Best regards

Sebastian
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry

Received on Do Dez 10 2015 - 22:53:12 CET

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:12 CET