function inversion and functional patterns

From: Wolfgang Jeltsch <wolfgang_at_cs.ioc.ee>
Date: Fri, 19 Apr 2013 22:35:08 +0300

Hi,

in Curry, we can define a generic function inversion operator as
follows:

> inverse :: (a -> b) -> (b -> a)
> inverse f y | f x =:= y = x where x free

Given that KiCS2 supports functional patterns, I tried to implement
function inversion in a simpler way as follows:

> inverse :: (a -> b) -> (b -> a)
> inverse f (f x) = x

However, this does not work. Neither does the following:

> inverse :: (a -> b) -> (b -> a)
> inverse f = \ (f x) -> x

I’m pretty sure that these alternative implementations are not covered
by the functional patterns extension, but I wonder whether it would be
reasonable to extend Curry even more such that the above code snippets
are accepted. What do you think?

Best wishes,
Wolfgang

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

Received on Fr Apr 19 2013 - 22:22:37 CEST

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