Functor Functors or Higher Kinded Data for PureScript

Did anyone already create a library for the Functor Functors[1] or Higher Kinded Data[2] pattern?

The HKD pattern that Sandy Maguire uses in his post[2] with a type family wouldn’t work in PureScript. But I think the classes from the Functor Functors[1] post can be easily translated into PureScript.

I came across this document [3] by Jordan Martinez, but it’s not adapted for records I think. I ran into some problems trying to adapt it.

[1] https://www.benjamin.pizza/posts/2017-12-15-functor-functors.html
[2] https://reasonablypolymorphic.com/blog/higher-kinded-data/
[3] https://github.com/JordanMartinez/purescript-jordans-reference/blob/7c0ee58dec5ddc2e57d84597c023a954eca4d47c/31-Design-Patterns/23-Higher-Kinded-Data.md

1 Like

We use the pattern quite a lot. It’s not without its flaws in the absence of type families, it can get a bit out of control, but yeah it’s great for the most part.

Classes: https://github.com/garyb/purescript-functor1

There’s also Eq1 and Ord1 in the Prelude, and deriving is supported for them and/or deriving with Eq1 constraints on an Eq type, etc.

1 Like

Thanks a lot @garyb! I’m going to try purescript-functor1.

If you find it’s missing any stuff you need, please do send PRs! It’s pretty minimal right now.