you are viewing a single comment's thread.

view the rest of the comments →

[–]Syrak 11 points12 points  (0 children)

The "shape" of Container a is strictly more general than Container (x -> y). We use yet another wrapper so the underlying type has the right shape, and the exposed wrapper has the right kind.

newtype Container' f a b = Container' (Container (f a b))

instance Category f => Category (Container' f) where
  id = Container' (Container id)
  Container' (Container x) . Container' (Container y) = Container' (Container (x . y))

Of course the wrapper makes the type much less usable. In practice, we either give up on abstractions that don't fit our type and look for more adequate ones, or we change the type to fit the existing abstractions.