# "Shortcut" for f (g x) (g x)

5 messages
Open this post in threaded view
|

## "Shortcut" for f (g x) (g x)

 Hello, All! Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for example:   compare (snd x) (snd x) Looks like combinatory logic or `ap` but not exactly... === Best regards, Paul _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: "Shortcut" for f (g x) (g x)

 You can use `liftM2 f g g` For the example you mentioned, there's also     compare `on` snd or     comparing snd with the proper imports (Data.Ord, Data.Function) On Mon, Dec 4, 2017 at 8:31 AM, Baa <[hidden email]> wrote: > Hello, All! > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for > example: > >   compare (snd x) (snd x) > > Looks like combinatory logic or `ap` but not exactly... > > === > Best regards, Paul > _______________________________________________ > Beginners mailing list > [hidden email] > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners-- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Open this post in threaded view
|

## Re: "Shortcut" for f (g x) (g x)

 In reply to this post by Paul Hi! I think you're looking for Data.Function.on: http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Function.html#v:onOn 04/12/2017, Baa <[hidden email]> wrote: > Hello, All! > > Does Haskell have some "short-form" for such call: `f (g x) (g x)`, for > example: > >   compare (snd x) (snd x) > > Looks like combinatory logic or `ap` but not exactly... > > === > Best regards, Paul > _______________________________________________ > 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