@@ -33,20 +33,18 @@ module Control.SIArrow (
3333 sireplicate_
3434 ) where
3535
36−import Control.Arrow (Kleisli(..))
36+import Control.Arrow
3737import Control.Category
38−import Control.Category.Structures
3938import Control.Lens.Cons
4039import Control.Lens.Empty
4140import Control.Lens.Iso
4241import Control.Lens.SemiIso
4342import Control.Monad
4443import Control.Tuple.Morph
45−import Data.Semigroupoid.Dual
4644import Prelude hiding (id, (.))
4745
48−infixr 1 ^>>, ^<<, #>>, #<<
49−infixr 1 >>^, <<^, >>#, <<#
46+infixr 1 #>>, #<<
47+infixr 1 >>#, <<#
5048infixl 4 /$/, /$~
5149infixl 5 /*/, */, /*
5250infixl 3 /?/
@@ -59,7 +57,7 @@ infixl 3 /?/
5957--
6058-- The category @cat@ should contain @SemiIso@ as a sort of
6159-- \"subcategory of pure computations\".
62−class (Products cat, Coproducts cat, CatPlus cat) => SIArrow cat where
60+class (Arrow cat, ArrowChoice cat, ArrowPlus cat) => SIArrow cat where
6361 -- | Allows you to lift a SemiIso into @cat@. The resulting arrow should be
6462 -- in some sense minimal or \"pure\", similiar to 'pure', 'return' and
6563 -- 'arr' from "Control.Category".
@@ -87,7 +85,7 @@ class (Products cat, Coproducts cat, CatPlus cat) => SIArrow cat where
8785
8886 -- | @simany v@ repeats @v@ as long as possible.
8987 simany :: cat () b -> cat () [b]
90− simany v = sisome v /+/ sipure _Empty
88+ simany v = sisome v <+> sipure _Empty
9189
9290 {-# MINIMAL (siarr | sipure), sibind #-}
9391
@@ -95,32 +93,12 @@ instance MonadPlus m => SIArrow (Kleisli m) where
9593 siarr ai = Kleisli $ either fail return . apply ai
9694 sibind ai = Kleisli $ \a -> either fail (($ a) . runKleisli) $ apply ai a
9795
98−instance SIArrow cat => SIArrow (Dual cat) where
99− siarr = Dual . sipure
100− sibind ai = Dual $ sibind (iso id getDual . rev ai . iso getDual id)
101−
10296instance SIArrow ReifiedSemiIso' where
10397 siarr = reifySemiIso
10498 sibind ai = ReifiedSemiIso' $
10599 semiIso (\a -> apply ai a >>= flip apply a . runSemiIso)
106100 (\b -> unapply ai b >>= flip unapply b . runSemiIso)
107101
108−-- | Composes a SemiIso with an arrow.
109−(^>>) :: SIArrow cat => ASemiIso' a b -> cat b c -> cat a c
110−f ^>> a = a . siarr f
111−
112−-- | Composes an arrow with a SemiIso.
113−(>>^) :: SIArrow cat => cat a b -> ASemiIso' b c -> cat a c
114−a >>^ f = siarr f . a
115−
116−-- | Composes a SemiIso with an arrow, backwards.
117−(^<<) :: SIArrow cat => ASemiIso' b c -> cat a b -> cat a c
118−f ^<< a = siarr f . a
119−
120−-- | Composes an arrow with a SemiIso, backwards.
121−(<<^) :: SIArrow cat => cat b c -> ASemiIso' a b -> cat a c
122−a <<^ f = a . siarr f
123−
124102-- | Composes a reversed SemiIso with an arrow.
125103(#>>) :: SIArrow cat => ASemiIso' b a -> cat b c -> cat a c
126104f #>> a = a . sipure f
@@ -171,7 +149,7 @@ ai /$<~> h = cloneSemiIso ai . reorderMorphed /$/ h
171149--
172150-- The uncurried analogue of '<*>'.
173151(/*/) :: SIArrow cat => cat () b -> cat () c -> cat () (b, c)
174−a /*/ b = unit ^>> (a *** b)
152+a /*/ b = siarr unit >>> (a *** b)
175153
176154-- | The product of two arrows, where the second one has no input and no output
177155-- (but can have side effects), with duplicate units removed. Side effect are
@@ -195,7 +173,7 @@ sifail = siarr . alwaysFailing
195173
196174-- | Provides an error message in the case of failure.
197175(/?/) :: SIArrow cat => cat a b -> String -> cat a b
198−f /?/ msg = f /+/ sifail msg
176+f /?/ msg = f <+> sifail msg
199177
200178-- | Equivalent of 'sequence'.
201179sisequence :: SIArrow cat => [cat () a] -> cat () [a]