File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,12 @@ instance bindCoyoneda :: Bind f => Bind (Coyoneda f) where
67
67
liftCoyoneda $
68
68
runExists (\(CoyonedaF k fi) -> lowerCoyoneda <<< f <<< k =<< fi) e
69
69
70
+ -- | When `f` is a Monad then it is a functor as well. In this case
71
+ -- | `liftCoyoneda` is not only a functor isomorphism but also a monad
72
+ -- | isomorphism, i.e. the following law holds
73
+ -- | ```purescript
74
+ -- | liftCoyoneda fa >>= liftCoyoneda <<< g = liftCoyoneda $ fa >>= g
75
+ -- | ```
70
76
instance monadCoyoneda :: Monad f => Monad (Coyoneda f )
71
77
72
78
instance monadTransCoyoneda :: MonadTrans Coyoneda where
@@ -76,6 +82,12 @@ instance extendCoyoneda :: Extend w => Extend (Coyoneda w) where
76
82
extend f (Coyoneda e) =
77
83
runExists (\(CoyonedaF k fi) -> liftCoyoneda $ f <<< coyoneda k <<= fi) e
78
84
85
+ -- | As in the monad case: if `w` is a comonad, then it is a functor, thus
86
+ -- | `liftCoyoneda` is an iso of functors, but moreover it is an iso of
87
+ -- | comonads, i.e. the following law holds:
88
+ -- | ```purescript
89
+ -- | g <<= liftCoyoneda w = liftCoyoneda $ g <<< liftCoyoneda <<= w
90
+ -- | ```
79
91
instance comonadCoyoneda :: Comonad w => Comonad (Coyoneda w ) where
80
92
extract (Coyoneda e) = runExists (\(CoyonedaF k fi) -> k $ extract fi) e
81
93
You can’t perform that action at this time.
0 commit comments