任意カテゴリにおける自由モノイド関数
1079 ワード
それはしばしば「モナドは内因性のカテゴリーの中のモノイドです.」
ほとんど知られていない事実は、アプリケーションの機能は、製品として日の畳み込みと機能のカテゴリのモノイドです.
また、エンドファンクションの構成と異なった日の畳み込みは、どんな強力なモノイドカテゴリーでも定義できます(基本的にはタプルと関数を持っています).
Hence
ためには、あなたのカテゴリを持っていない可能性のある機能を必要とするフルアプリケーションの機能を持っている.
ほとんど知られていない事実は、アプリケーションの機能は、製品として日の畳み込みと機能のカテゴリのモノイドです.
また、エンドファンクションの構成と異なった日の畳み込みは、どんな強力なモノイドカテゴリーでも定義できます(基本的にはタプルと関数を持っています).
Hence
{-# LANGUAGE ExistentialQuantification, RankNTypes #-}
import Prelude hiding (Functor (..), Applicative (..))
class Functor f where
fmap :: Hom a b -> f a -> f b
class Functor f => Monoidal f where
pure :: Id a -> f a
join :: Day f f a -> f a
data Day f g a = forall x y. Day (f x) (g y) (Hom (PRODUCT x y) a)
instance Functor (Day f g) where
fmap f (Day h x y) = Day (f :.: h) x y
data Id a = Id (forall x. Hom x a)
instance Functor Id where
fmap f (Id x) = Id (f :.: x)
data Free f a = Pure (Id a) | Ap (Day f (Free f) a)
instance Functor (Free f) where
fmap f (Pure x) = Pure (fmap f x)
fmap f (Ap x) = Ap (fmap f x)
instance Monoidal (Free f) where
pure = Pure
join (Day h (Pure x) y) = Ap h x y
PRODUCT
とHom
が定義されている場合.ためには、あなたのカテゴリを持っていない可能性のある機能を必要とするフルアプリケーションの機能を持っている.
Reference
この問題について(任意カテゴリにおける自由モノイド関数), 我々は、より多くの情報をここで見つけました https://dev.to/mspondee/free-monoidal-functors-in-arbitrary-categories-3kbpテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol