# Pointfree style

4 messages
Open this post in threaded view
|

## Pointfree style

 Hi, I'm trying to understand pointfree style better, but it's not coming along as well as I'd like it to. The thing I can't get to work is to reduce an argument that is used more than once in a function. My function looks like this now (which works like it should): f x = g ((h . i) x) x But I'd like to reduce the last argument x. I've looked at the wiki[1] but I couldn't find a systematic way to obtain pointfree functions when they get more complicated. Any pointers to pages or papers with more examples of obtaining pointfree functions are appreciated. Thanks, Bas van Gijzel [1]http://www.haskell.org/haskellwiki/Pointfree-------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20081111/444ea4fd/attachment.htm
Open this post in threaded view
|

## Pointfree style

 Am Dienstag, 11. November 2008 12:40 schrieb Bas van Gijzel: > Hi, > > I'm trying to understand pointfree style better, but it's not coming along > as well as I'd like it to. > The thing I can't get to work is to reduce an argument that is used more > than once in a function. > > My function looks like this now (which works like it should): > f x = g ((h . i) x) x > > But I'd like to reduce the last argument x. I've looked at the wiki[1] but > I couldn't find a systematic way to obtain pointfree functions when they > get more complicated. > Any pointers to pages or papers with more examples of obtaining pointfree > functions are appreciated. lambdabot can pointfree your functions, the command is @pl: lambdabot> @pl \x -> \y -> (y,x) flip (,) lambdabot> @pl \x -> g ((h . i) x) x g =<< h . i (the monad here is ((->) a), where x :: a, I think, you need Control.Monad.Instances for that to be in scope). I'm not sure reading lambdabot's sources is a good way to learn how to systematically pointfree functions, but looking at lambdabot's results should help. > > Thanks, > > Bas van Gijzel > > > [1]http://www.haskell.org/haskellwiki/PointfreeCheers, Daniel