1. 2

    Thanks @jnape for inspiring my interest in this very interesting problem. I must admit, however, I am having a difficult time understanding the implications of variance in a language like Haskell, as my (very young) understanding of the idea is qualified by the requirement of mutability. When you say “Covariant from A to B”, do you mean covariant in A and contravariant in B?

    Second, unless I am missing something (I’m sure I am, but I don’t believe it’s this), you are both using the notion of fixity in a strange way. Argument order and fixity AFAIK aren’t analogous… also, fmap is associative by definition, so the fixity of the compose operator is algebraically irrelevant.

    1. 1

      When you say “Covariant from A to B”, do you mean covariant in A and contravariant in B?

      This was in the context of fmap, meaning fmap :: Functor f => (a -> b) -> f a -> f b, rather than fmap :: Functor f => (b -> a) -> f a -> f b, which would be a contravariant fmap, or contramap as it is sometimes referred to.

      Argument order and fixity AFAIK aren’t analogous

      Your instincts are correct. Right infix plays to haskell’s lazy evaluation strengths (a great example here), so in terms of performance, it’s advantageous, but in terms of correctness, it’s irrelevant. In the Java case, however, it could likely mean that the parameter used for the current functor could be derived later at the call site from the argument, rather than up front from the method invocation, allowing fmap to be an operand of the argument, rather than the instance it’s invoked on. This is speculative, and I admittedly did a poor job explaining this. Sorry for that; don’t get hung up on it.