Skip to content

Instantly share code, notes, and snippets.

View bens's full-sized avatar

Ben Sinclair bens

  • Sydney, Australia
  • 02:22 (UTC +10:00)
View GitHub Profile
How do we add extra information to a tree? This has been called [The
AST Typing
Problem](http://blog.ezyang.com/2013/05/the-ast-typing-problem/).
After being hit with this problem in Roy's new type-inference engine,
I tried figuring out how to represent the algorithm. I eventually
realised that it looked like a comonadic operation. Turns out it's
been done before but I couldn't find any complete example.
Below is some literate Haskell to show how to use the Cofree Comonad