Where to find theoretical background (i.e., resources) behind PureScript classes?

Hello All,

Started learning PureScript by going through “PureScript by Example” (I think Dustin Whitney’s version is the most up to date version), and as it is pretty dense, I am taking detours from time to time to connect the dots via the Haskell Book, A guide to the PureScript numeric hierarchy (a huge help for someone like me without formal math background!) and Bartosz Milewski’s Category Theory for Programmers (github com/hmemcpy/milewski-ctfp-pdf).

I love how granular PureScript’s type system is, and would like to read more about their theoretical backgrounds, but I am having trouble finding any papers on them. For example, purescript-control's type class hierarchy has Plus, Alt, Alternative, Extend etc. that have no corresponding classes in Haskell, for example. The documentation is clear though, for example Plus is Monoid and Alt is Semigroup for * -> * kinded types, but I haven’t met these anywhere else before. (Not a surprise as I’m just starting out, and these may be named differently elsewhere).

Thank you for the help!

Appreciatively,
Attila

3 Likes

Regarding why PureScript’s typeclass hierarchy is so granular, I always refer to Phil’s blog post: https://blog.functorial.com/posts/2015-12-06-Counterexamples.html

Lately I’ve been discovering that having Bind and Applicative separate (without implementing Monad) is very useful for validation (aka obtaining better errors in general – compiler type errors, in my specific area of interest).

If you’re interested in the theory of how typeclasses are designed, I don’t know if there is a single paper that addresses it, but I bet there’s papers that address the features – the general requirement for uniqueness of instances and how type “heads” are matched, functional dependencies, and now instance chains. Overlapping and orphan instances are two concerns that also fit into the discussion.

@kritzcreek wrote a thesis that is a good resource that explains how solving typeclasses works.

And while we’re on the subject of the various typeclasses, I like this article a lot: http://conal.net/papers/type-class-morphisms/

1 Like

The more granular hierarchy is not in Haskell’s standard library (base) but my impression is that the design was largely inspired by similar efforts in Haskell - in particular, the semigroupoids package. I don’t know much about their theoretical background but I imagine the semigroupoids package is probably a good place to start.

1 Like

Mitchell has a nice listing of papers here: https://mitchellwrosen.github.io/haskell-papers

On the theoretical side, here’s one on how fundeps work: https://gkaracha.github.io/papers/fundeps.pdf (I haven’t read it)

And this paper covers a slew of typeclasses, but it doesn’t explain their reasoning in depth, mostly covers their free constructions: https://lirias.kuleuven.be/bitstream/123456789/499951/1/main.pdf (I’ve read it but honestly can’t summarize it)

1 Like

Thanks a lot for all the resources! I am all set with reading materials for the next couple months:)