Situation
I have a function fthat I want to increase using a function g, as a result we get a function with a name h.
Definitions
By "complement" in the general case, I mean: transform either the input (one or more arguments) or the output (return value) of the function f.
By "addition" in a specific case (specific to my current situation) I mean: convert only the output (return value) of the function f, leaving all arguments intact.
By “transparent” in the context of “increase” (both for the general case and for the specific case) I mean: “Connect the implementation gas little as possible with the implementation f.
Specific case
In my current situation, this is what I need to do:
h a b c = g $ f a b c
I am interested in rewriting it to something like this:
h = g . f -- Doesn't type-check.
Since hit gdoes not matter from the point of view which arguments fare taken, they only care about the return value, so it would be a tough connection to mention the arguments in any way. For example, if the number of arguments fchanges in the future, you will also need to change h.
Till
I asked lambdabot on the #haskell: IRC channel @pl h a b c = g $ f a b c, to which I received a response:
h = ((g .) .) . f
, (.) f.
, erisco #haskell http://matt.immute.net/content/pointless-fun, .
, , , :
h = f $. id ~> id ~> id ~> g
, , , , f, f - .
JavaScript, , :
function h () { return g(f.apply(this, arguments)) }
" " Haskell?
, , .