This repository was archived by the owner on May 24, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +37
-14
lines changed
Expand file tree Collapse file tree 4 files changed +37
-14
lines changed Original file line number Diff line number Diff line change 22 "name" : " purescript-arrows" ,
33 "homepage" : " https://github.com/purescript-contrib/purescript-arrows" ,
44 "authors" : [
5- " Phil Freeman <[email protected] >" 5+ " Phil Freeman <[email protected] >" ,
6+ " Gary Burgess <[email protected] >" 67 ],
78 "description" : " Type classes for Arrows" ,
89 "keywords" : [
2122 " package.json"
2223 ],
2324 "dependencies" : {
24- "purescript-tuples" : " *"
25+ "purescript-tuples" : " ~0.2.3" ,
26+ "purescript-profunctor" : " ~0.0.2"
2527 }
2628}
Original file line number Diff line number Diff line change 44
55### Type Classes
66
7- class (Category a) <= Arrow a where
7+
8+ class (Category a, Strong a) <= Arrow a where
9+
810 arr :: forall b c. (b -> c) -> a b c
9- first :: forall b c d. a b c -> a (Tuple b d) (Tuple c d)
11+
1012
1113 class ArrowPlus a where
14+
1215 (<+>) :: forall b c. a b c -> a b c -> a b c
1316
17+
1418 class ArrowZero a where
19+
1520 azero :: forall b c. a b c
1621
1722
1823### Type Class Instances
1924
25+
2026 instance arrowFunction :: Arrow Prim.Function
2127
2228
2329### Values
2430
31+
2532 (&&&) :: forall a b b' c c'. (Arrow a) => a b c -> a b c' -> a b (Tuple c c')
2633
27- (***) :: forall a b b' c c'. (Arrow a) => a b c -> a b' c' -> a (Tuple b b') (Tuple c c')
2834
29- second :: forall a b c d . (Arrow a) => a b c -> a (Tuple d b ) (Tuple d c )
35+ (***) :: forall a b b' c c' . (Arrow a) => a b c -> a b' c' -> a (Tuple b b' ) (Tuple c c' )
3036
3137
3238## Module Control.Arrow.Kleisli
3339
3440### Types
3541
42+
3643 newtype Kleisli m a b where
37- Kleisli :: a -> m b -> Kleisli m a b
44+ Kleisli :: ( a -> m b) -> Kleisli m a b
3845
3946
4047### Type Class Instances
4148
49+
4250 instance arrowKleisli :: (Monad m) => Arrow (Kleisli m)
4351
52+
4453 instance categoryKleisli :: (Monad m) => Category (Kleisli m)
4554
55+
56+ instance profunctorKleisli :: (Functor f) => Profunctor (Kleisli f)
57+
58+
4659 instance semigroupoidKleisli :: (Monad m) => Semigroupoid (Kleisli m)
4760
4861
62+ instance strongKleisli :: (Monad m) => Strong (Kleisli m)
63+
64+
4965### Values
5066
67+
5168 runKleisli :: forall m a b. Kleisli m a b -> a -> m b
Original file line number Diff line number Diff line change 11module Control.Arrow where
22
3+ import Data.Profunctor.Strong
34import Data.Tuple (Tuple (..), swap )
45
5- class (Category a ) <= Arrow a where
6+ class (Category a , Strong a ) <= Arrow a where
67 arr :: forall b c . (b -> c ) -> a b c
7- first :: forall b c d . a b c -> a (Tuple b d ) (Tuple c d )
88
99instance arrowFunction :: Arrow (-> ) where
1010 arr f = f
11- first f (Tuple b d) = Tuple (f b) d
12-
13- second :: forall a b c d . (Arrow a ) => a b c -> a (Tuple d b ) (Tuple d c )
14- second f = arr swap >>> first f >>> arr swap
1511
1612infixr 3 ***
1713infixr 3 &&&
Original file line number Diff line number Diff line change 11module Control.Arrow.Kleisli where
22
33import Control.Arrow
4+ import Data.Profunctor
5+ import Data.Profunctor.Strong
46import Data.Tuple (Tuple (..), swap )
57
68newtype Kleisli m a b = Kleisli (a -> m b )
@@ -14,6 +16,12 @@ instance semigroupoidKleisli :: (Monad m) => Semigroupoid (Kleisli m) where
1416instance categoryKleisli :: (Monad m ) => Category (Kleisli m ) where
1517 id = Kleisli return
1618
19+ instance profunctorKleisli :: (Functor f ) => Profunctor (Kleisli f ) where
20+ dimap f g (Kleisli h) = Kleisli ((<$>) g <<< h <<< f)
21+
22+ instance strongKleisli :: (Monad m ) => Strong (Kleisli m ) where
23+ first (Kleisli f) = Kleisli \(Tuple a c) -> f a >>= \b -> return (Tuple b c)
24+ second (Kleisli f) = Kleisli \(Tuple c a) -> f a >>= \b -> return (Tuple c b)
25+
1726instance arrowKleisli :: (Monad m ) => Arrow (Kleisli m ) where
1827 arr f = Kleisli (return <<< f)
19- first (Kleisli f) = Kleisli \(Tuple b d) -> f b >>= \c -> return (Tuple c d)
You can’t perform that action at this time.
0 commit comments