Functor instance for generic polymorphic ADTs in Haskell?
问题 When it comes to applying category theory for generic programming Haskell does a very good job, for instance with libraries like recursion-schemes . However one thing I'm not sure of is how to create a generic functor instance for polymorphic types. If you have a polymorphic type, like a List or a Tree, you can create a functor from (Hask × Hask) to Hask that represents them. For example: data ListF a b = NilF | ConsF a b -- L(A,B) = 1+A×B data TreeF a b = EmptyF | NodeF a b b -- T(A,B) = 1+A