git.iko.soy/semi-iso-optics
on master help sign in
Add comment, remove (~$/) and (~$~) for clarity.
commit94f0a75e92da925cf4872be634ad38609c213f9e authorPaweł Nowak <pawel834@gmail.com> dateThu 11 Dec 2014, 16:38 (12 years ago) parentc97679d
2 files changed+27−17
Control/Category/Structures.hs+8 Control/SIArrow.hs+19−17
Control/Category/Structures.hs+8
@@ -9,6 +9,10 @@ License : MIT
99Maintainer : Paweł Nowak <pawel834@gmail.com>
1010Stability : experimental
1111
12+This module defines some basic structures in a category in a more fine-grained
13+way then "Control.Arrow".
14+
15+Unfortunately names in this module clash with "Control.Arrow".
1216-}
1317module Control.Category.Structures where
1418
@@ -22,6 +26,7 @@ infixl 3 ***
2226infixl 2 +++
2327infixl 3 /+/
2428
29+-- | A category with finite products.
2530class Category cat => Products cat where
2631 first :: cat a b -> cat (a, c) (b, c)
2732 first a = a *** id
@@ -37,6 +42,7 @@ class Category cat => Products cat where
3742instance Monad m => Products (Kleisli m) where
3843 (***) = (BadArrow.***)
3944
45+-- | A category with finite coproducts.
4046class Category cat => Coproducts cat where
4147 left :: cat a b -> cat (Either a c) (Either b c)
4248 left a = a +++ id
@@ -52,6 +58,7 @@ class Category cat => Coproducts cat where
5258instance Monad m => Coproducts (Kleisli m) where
5359 (+++) = (BadArrow.+++)
5460
61+-- | A category @cat@ is a CatPlus when @cat a b@ is a monoid for all a, b.
5562class Category cat => CatPlus cat where
5663 cempty :: cat a b
5764 (/+/) :: cat a b -> cat a b -> cat a b
@@ -62,6 +69,7 @@ instance MonadPlus m => CatPlus (Kleisli m) where
6269 cempty = BadArrow.zeroArrow
6370 (/+/) = (BadArrow.<+>)
6471
72+-- | A category transformer.
6573class CategoryTrans t where
6674 clift :: Category cat => cat a b -> t cat a b
6775
Control/SIArrow.hs+19−17
@@ -10,7 +10,24 @@ Maintainer : Paweł Nowak <pawel834@gmail.com>
1010Stability : experimental
1111
1212-}
13−module Control.SIArrow where
13+module Control.SIArrow (
14+ -- * Arrow.
15+ SIArrow(..),
16+ (^>>), (>>^), (^<<), (<<^),
17+
18+ -- * Functor and applicative.
19+ (/$/), (/$~),
20+ (/*/), (/*), (*/),
21+
22+ -- * Signaling errors.
23+ sifail, (/?/),
24+
25+ -- * Combinators.
26+ sisequence,
27+ sisequence_,
28+ sireplicate,
29+ sireplicate_
30+ ) where
1431
1532import Control.Arrow (Kleisli(..))
1633import Control.Category
@@ -24,7 +41,7 @@ import Prelude hiding (id, (.))
2441
2542infixr 1 ^>>, >>^
2643infixr 1 ^<<, <<^
27−infixl 4 /$/, /$~, ~$/, ~$~
44+infixl 4 /$/, /$~
2845infixl 5 /*/, */, /*
2946
3047-- Categories.
@@ -75,21 +92,6 @@ ai /$/ f = sipure ai . f
7592 => ASemiIso' a b' -> cat c b -> cat c a
7693ai /$~ h = cloneSemiIso ai . morphed /$/ h
7794
78−-- | > ai ~$/ f = morphed . ai /$/ f
79−(~$/) :: (SIArrow cat, HFoldable a', HFoldable a,
80− HUnfoldable a', HUnfoldable a, Rep a' ~ Rep a)
81− => ASemiIso' a' b -> cat c b -> cat c a
82−ai ~$/ h = morphed . cloneSemiIso ai /$/ h
83−
84−-- | > ai ~$~ f = morphed . ai . morphed /$/ f
85−(~$~) :: (SIArrow cat,
86− HFoldable a, HUnfoldable a,
87− HFoldable b, HUnfoldable b,
88− HFoldable b', HUnfoldable b',
89− Rep b' ~ Rep b, Rep b' ~ Rep a)
90− => ASemiIso b' b' b' b' -> cat c b -> cat c a
91−ai ~$~ h = morphed . cloneSemiIso ai . morphed /$/ h
92−
9395(/*/) :: SIArrow cat => cat () b -> cat () c -> cat () (b, c)
9496a /*/ b = unit ^>> (a *** b)
9597