External Publication
Visit Post

Error GHC-91510: illegal polymorphic type

Haskell Community [Unofficial] June 23, 2026
Source

OMG, I solved it!

type C0 :: k -> Constraint
class C0 x
instance C0 x

type CCompose :: (k -> Constraint) -> (j -> k) -> Constraint
class (forall x. (c (f x))) => CCompose c f

type Category :: (k -> k -> Type) -> Constraint
class Category cat where
  type Objects cat :: k -> Constraint -- changed
  id :: (Objects cat x) => cat x x
  (.) ::
    (Objects cat x, Objects cat y, Objects cat z) =>
    cat y z -> cat x y -> cat x z

instance (Category c, Category d) => Category (Transform c d) where
  type Objects (Transform c d) = CCompose (Objects d) -- nice!
  id :: (Objects (Transform c d) f) => Transform c d f f
  id = Transform id
  (.) ::
    ( Objects (Transform c d) f
    , Objects (Transform c d) g
    , Objects (Transform c d) h
    ) =>
    Transform c d g h -> Transform c d f g -> Transform c d f h
  Transform g_h . Transform f_g = Transform (g_h . f_g)

Compiles! Thanks for pointing me in the right direction @Leary!

Discussion in the ATmosphere

Loading comments...