Composing f: (a: A) => B and g: (b: B) => C is trivial by normal function composition.
What is challenging is composing f and g when output type of f isn't the same as input type of g. And that is impossible to do if these output-input types are completely arbitrary.
So what we do is we try to introduce some dependency between them ("what if output of f is F<input of g>?") and see if we can somehow compose them NOW, with that constraint in place.
Composing
f: (a: A) => Bandg: (b: B) => Cis trivial by normal function composition.What is challenging is composing
fandgwhen output type offisn't the same as input type ofg. And that is impossible to do if these output-input types are completely arbitrary.So what we do is we try to introduce some dependency between them ("what if output of
fisF<input of g>?") and see if we can somehow compose them NOW, with that constraint in place.Turns out we CAN - if F is a functor.
Taking the concrete problem of two generic functions f: (a: A) => B and g: (c: C) => D
Can you show how a Response Functor solves the composition when B != C