Hacker News new | ask | show | jobs
by cottonseed 2109 days ago
> Function composition is always associative.

You're still confused. There is no function composition here.

op in the example above is just some other function, like +. The associativity of + and function composition are true for totally unrelated reasons. Associativity of plus is an inductive argument that follows from the Peano axioms.

Function composition says:

(f o g) o h = f o (g o h)

as functions. It is true because unary function application "serializes" function applications. Formally, I mean:

    ((f o g) o h)(x)
      = f(g(h(x)))
      = (f o (g o h))(x)
Function composition has one value flowing through several functions. Fold has several values flowing through one function.
1 comments

It's a higher order composition of functors. Lack of Commutativity still applies and is the factor for why the codomains aren't equal not associativity. It's all pedantry though. Overall you're right.

Intuitively the composition is similar enough to function composition that is has the same basic ruleset and is how I'm working out the logic in my head. Think of the functor as a tuple of the accumulator and the value: (acc, x), and the function is just an op that takes in this tuple as a parameter and spits out a new tuple (acc, z) with the next value in the list.

I addressed it earlier here: https://news.ycombinator.com/item?id=24449271