임의의 범주 중의 자유 반함
편지의 응용은 편지의 범주 중의 반군이고 그 곱셈은 일권적이다.
내신자 합성과 달리 일권적은 어떤 강호반류에도 정의할 수 있다(기본적으로 원조와 함수만 있다)
그러므로
{-# 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.)