1
votes

In functional composition g compose f what terms are used to refer to and differentiate the ordering property of functional arguments f and g passed to composition operator compose? For example, given the following compositions

val reverse = (s: String) => s.reverse
val dropThree = (s: String) => s.drop(3)

(reverse compose dropThree)("Make it so!") // ==> !os ti e: java.lang.String
(dropThree compose reverse)("Make it so!") // ==> ti ekaM: java.lang.String

what terminology makes explicit reverse comes after in

reverse compose dropThree

whilst it comes first in

dropThree compose reverse

Over at Math SE they seem to think such precise terminology has not yet emerged

...I'd aim for an analogy with division or subtraction: you might, for instance, call the outer function the composer and the inner the composand. Words like this are not (as far as I know) in common use, perhaps because the need for them hasn't arisen as often as those for the elementary arithmetic operations.

however, in software engineering world, composition, chaining, pipelining, etc. seems ubiquitous, and is bread-and-butter of functional programming, thus there ought to exist precise terminology characterising the crucial ordering property of operands involved in composition.

Note the terms the question is after refer specifically to particular arguments of composition, not the whole expression, akin to divisor and dividend which precisely describe which is which in division.

1
reverse compose dropThree is Scala, and equivalent to reverse.compose(dropThree), right? - Bergi
Yes, in Scala punctation may be dropped in infix notation. - Mario Galic

1 Answers

1
votes

I don't think there's any formal terminology, but I would express a ∘ b (λx.a(b(x))) as

  • composition of a and b
  • a composed with b
  • a composed onto b
  • a chained onto b
  • a after b
  • b before a
  • x pipelined through b and a

As for the designations of the arguments to the compose function, I guess you're left with the Math.SE answer.