foldr point free notation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

foldr point free notation

Alexander Chen
hi,

--any function foldr
myAny'' :: (a-> Bool) -> [a] -> Bool
myAny'' f = foldr (\a b -> f a || b) False

this is the foldr notions. How would i make this point free?

best,

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: foldr point free notation

Bob Ippolito
The better question is why would you want to? If you could even manage, the result would be practically incomprehensible. 

On Wed, Jun 10, 2020 at 07:49 Alexander Chen <[hidden email]> wrote:
hi,

--any function foldr
myAny'' :: (a-> Bool) -> [a] -> Bool
myAny'' f = foldr (\a b -> f a || b) False

this is the foldr notions. How would i make this point free?

best,
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: foldr point free notation

Apoorv Ingle
Hi Alexander,

I found this tool online[1], that converts your function to a point free style.

myAny'' f = foldr (\a b -> f a || b) False

is transformed to

myAny'' = flip foldr False . ((||) .)

Again as Bob mentions, the point free style comes at a cost of unreadability and hence unmaintainable. 

Cheers!
Apoorv

On Jun 10, 2020, at 10:00, Bob Ippolito <[hidden email]> wrote:

The better question is why would you want to? If you could even manage, the result would be practically incomprehensible. 

On Wed, Jun 10, 2020 at 07:49 Alexander Chen <[hidden email]> wrote:
hi,

--any function foldr
myAny'' :: (a-> Bool) -> [a] -> Bool
myAny'' f = foldr (\a b -> f a || b) False

this is the foldr notions. How would i make this point free?

best,
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners