[Haskell-beginners] Pointfree style

Daniel Fischer daniel.is.fischer at web.de
Tue Nov 11 08:20:03 EST 2008

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 

> Thanks,
> Bas van Gijzel
> [1]http://www.haskell.org/haskellwiki/Pointfree


More information about the Beginners mailing list