Error GHC-91510: illegal polymorphic type
Haskell Community [Unofficial]
June 21, 2026
With enough type-class synonyms
class Objects cat x => ObjectClass cat x
instance Objects cat x => ObjectClass cat x
class (forall x. f x => g x) => f ==> g
instance (forall x. f x => g x) => f ==> g
infix 2 ==>
class f (g x) => (f . g) x
instance f (g x) => (f . g) x
and a few tweaks to your implementation (which I think are fixes)
type Transform ::
(k -> k -> Type) ->
(j -> k) ->
(j -> k) ->
Type
newtype Transform cat f g = Transform
{transform :: forall x. Objects cat x => cat (f x) (g x)}
instance (Category cat) => Category (Transform cat) where
type Objects (Transform cat) f = ObjectClass cat ==> ObjectClass cat . f
id = Transform id
Transform g_h . Transform f_g = Transform (g_h . f_g)
all looks to be well.
Discussion in the ATmosphere