Haskell:monoidal类别中的态射构成

对于monoidal类别类,我有以下定义(类似于标准库,但提供必要的自然同构反转):

class (Category r, Category s, Category t) => Bifunctor p r s t | p r -> s t, p s -> r t, p t -> r s where
  bimap :: r a b -> s c d -> t (p a c) (p b d)
--
class (Bifunctor b k k k) => Associative k b where
  associate :: k (b (b x y) z) (b x (b y z))  
  associateInv :: k (b x (b y z)) (b (b x y) z)
--
class (Bifunctor b k k k) => HasIdentity k b i | k b -> i
class (Associative k b, HasIdentity k b i) => Monoidal k b i | k b -> i where
  idl :: k (b i a) a
  idr :: k (b a i) a
  idlInv :: k a (b i a)
  idrInv :: k a (b a i)
--

使用(.)构造monoidal范畴中的态射的问题是对象可能以不同方式关联。 instance Monoidal Hask (,) () ,我们可能想要Monoidal Hask (,) ()一个类型为x -> ((a, b), c)的态射具有类型为((a, ()), (b, c)) -> y的态射((a, ()), (b, c)) -> y 。 为了使这些类型适合,由bimap idrInv id . associate给出的自然同构bimap idrInv id . associate bimap idrInv id . associate必须得到应用。

Haskell类型系统是否基于期望的域和共域类型启用了自动确定适当同构的方式? 我无法弄清楚如何去做。

链接地址: http://www.djcxy.com/p/43315.html

上一篇: Haskell: Composition of morphisms in monoidal categories

下一篇: Why is `pure` only required for Applicative and not already for Functor?