"Composition of Composition" (i.e., (.) . (.)) in Haskell), has type (a -> b) -> (c -> d -> a) -> c -> d -> b. Apparently, this is an instance of fmap, i.e. a functor between two categories.

The question is: what is the domain and the codomain of this functor? How do we interpret this functor in terms of functional programming?

  • $\begingroup$ No, fmap can not have that type. fmap . fmap can, since fmap = (.) for the functor X -> - (for any X). In your case, the two functors are c -> - and d -> -. (For total obfuscation, fmap . fmap can be also be written as fmap fmap fmap) $\endgroup$ – chi Nov 30 '18 at 17:22
  • $\begingroup$ Anyway, I think that this question is a bit too much Haskell-specific to be here. On StackOverflow we routinely handle Haskell questions asking for the underlying categorical ideas (and how faithfully, or not, they appear in Haskell). $\endgroup$ – chi Nov 30 '18 at 17:25
  • $\begingroup$ @chi It is certainly not true that this question is specific to Haskell - we get categories in any pure subset of typed functional programming languages. Writing this in SML for instance does not magically change the categories involved. $\endgroup$ – xuq01 Nov 30 '18 at 21:12
  • $\begingroup$ @xuq01 Actually, it likely does change the categories involved (at least to the extent that it is meaningful to talk about categories). $\endgroup$ – Derek Elkins Dec 1 '18 at 17:29

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.