1. 11
  1.  

  2. 4

    In The Screwtape Letters, Lewis describes a “materialist magician,” a person who simultaneously engages in magical rituals which have a spiritual purpose and also insists that the realm of the divine is imaginary, in order to highlight the doublethink inherent in folks’ casual invocation of supposedly-spiritual phenomena or beings. Similarly, the article’s author is engaged in a sort of ritualized usage of mathematical concepts, but they ignore the algebraic and logical origins.

    When the author writes that “interfaces are adjectives,” they are insisting on a particular linguistic attitude which ignores the history of Carnap’s function words. For example, Carnap would suggest that the word “and” is a functor, and today we often identify this as the tensor product functor of monoidal categories.

    This [Haskell typeclass] is the full definition. There is no additional hidden machinery that Haskell is somehow automatically invoking when you “use a Functor”. … What makes a data structure “functorish”? It is having a sensible implementation of fmap, whatever that may be on the data structure. If it has a sensible implementation, we can give it, that makes it a Functor, not the other way around.

    Without the algebra, it’s only half-complete. When using GHC, Functor instances can be automatically derived. This relies on the fact that, when we add the algebraic law fmap id == id to our equations, a Haskell datatype can only have one legal and correct Functor instance. If Hask were a category, then Functors would indeed be endofunctors on Hask. The author says that these important details were “glossed over with malice aforethought,” which is a weird flex.

    Let me highlight that there’s nothing about “monad” that is somehow “requiring” the implementation on list to be flatmap.

    Today I learned that there is an exotic list monads package on Hackage.

    1. 5

      This relies on the fact that, when we add the algebraic law fmap id == id to our equations, a Haskell datatype can only have one legal and correct Functor instance.

      Huh. Do you know of a good way to prove this? It certainly seems intuitively true to me, but I don’t have the category theory machinery. (And is it true even in the presence of undefined?)

      Overall I think you’re being a bit harsh, and this is as someone that knows Haskell and just enough category theory to be dangerous. The idea of a functor or a monad is plenty useful even in languages that don’t have the academic pedigree that Haskell does, and while you certainly can’t fully appreciate them without category theory, if you want a working programmer’s understanding I think it’s alright to push that aside.