I’ve just released an initial version of https://github.com/natefaubion/purescript-heterogeneous which aims to make writing maps and folds over stuff like Record a lot easier and more approachable. I’ve written up a short README which covers the basics of using it (with Records at least), and I’ve included some examples in the tests. One is an implementation of
HList which supports
hfoldlWithIndex with Peano numerals for indexing.
Some interesting points/issues:
- Never write boilerplate Row.Cons instances again!
- The fundeps are very flexible (and thus inference may not be as good). One example is that you can write type-aligned folds where the accumulator type changes with every step.
- Inference is weird for the bare function case, so you have to make sure its monomorphic. Maybe related to fundeps?
Anyway, I’d love to hear thoughts and feedback.