Skip to content

Instantly share code, notes, and snippets.

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString

Keybase proof

I hereby claim:

  • I am noordinaryguy on github.
  • I am neiljord (https://keybase.io/neiljord) on keybase.
  • I have a public key ASDRjJ15P2F2UYKGrSPnk8kIuzSOf85FcGcT_Ea8SoXBKwo

To claim this, I am signing this object:

Verifying that +neilord is my blockchain ID. https://onename.com/neilord