File tree Expand file tree Collapse file tree 3 files changed +56
-3
lines changed Expand file tree Collapse file tree 3 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,20 @@ instance choiceArr :: Choice Prim.Function
50
50
```
51
51
52
52
53
+ #### ` (+++) `
54
+
55
+ ``` purescript
56
+ (+++) :: forall p a b c d. (Category p, Choice p) => p a b -> p c d -> p (Either a c) (Either b d)
57
+ ```
58
+
59
+
60
+ #### ` (|||) `
61
+
62
+ ``` purescript
63
+ (|||) :: forall p a b c. (Category p, Choice p) => p a c -> p b c -> p (Either a b) c
64
+ ```
65
+
66
+
53
67
54
68
## Module Data.Profunctor.Strong
55
69
@@ -66,4 +80,18 @@ class (Profunctor p) <= Strong p where
66
80
67
81
``` purescript
68
82
instance strongArr :: Strong Prim.Function
83
+ ```
84
+
85
+
86
+ #### ` (***) `
87
+
88
+ ``` purescript
89
+ (***) :: forall p a b c d. (Category p, Strong p) => p a b -> p c d -> p (Tuple a c) (Tuple b d)
90
+ ```
91
+
92
+
93
+ #### ` (&&&) `
94
+
95
+ ``` purescript
96
+ (&&&) :: forall p a b c. (Category p, Strong p) => p a b -> p a c -> p a (Tuple b c)
69
97
```
Original file line number Diff line number Diff line change 1
1
module Data.Profunctor.Choice where
2
2
3
- import Data.Either (Either (..))
4
- import Data.Profunctor ( Profunctor )
3
+ import Data.Either (Either (..), either )
4
+ import Data.Profunctor
5
5
6
6
class (Profunctor p ) <= Choice p where
7
7
left :: forall a b c. p a b -> p (Either a c ) (Either b c )
@@ -12,3 +12,15 @@ module Data.Profunctor.Choice where
12
12
left _ (Right c ) = Right c
13
13
14
14
right = (<$>)
15
+
16
+ infixr 2 +++
17
+ infixr 2 |||
18
+
19
+ (+++) :: forall p a b c d. (Category p , Choice p ) => p a b -> p c d -> p (Either a c ) (Either b d )
20
+ (+++) l r = left l >>> right r
21
+
22
+ (|||) :: forall p a b c. (Category p , Choice p ) => p a c -> p b c -> p (Either a b ) c
23
+ (|||) l r = (l +++ r ) >>> join
24
+ where
25
+ join :: p (Either c c ) c
26
+ join = dimap (either id id ) id id
Original file line number Diff line number Diff line change 1
1
module Data.Profunctor.Strong where
2
2
3
- import Data.Profunctor ( Profunctor )
3
+ import Data.Profunctor
4
4
import Data.Tuple (Tuple (..))
5
5
6
6
class (Profunctor p ) <= Strong p where
@@ -10,3 +10,16 @@ module Data.Profunctor.Strong where
10
10
instance strongArr :: Strong (->) where
11
11
first a2b (Tuple a c ) = Tuple (a2b a ) c
12
12
second = (<$>)
13
+
14
+ infixr 3 ***
15
+ infixr 3 &&&
16
+
17
+ (***) :: forall p a b c d. (Category p , Strong p ) => p a b -> p c d -> p (Tuple a c ) (Tuple b d )
18
+ (***) l r = first l >>> second r
19
+
20
+ (&&&) :: forall p a b c. (Category p , Strong p ) => p a b -> p a c -> p a (Tuple b c )
21
+ (&&&) l r = split >>> (l *** r )
22
+ where
23
+ split :: p a (Tuple a a )
24
+ split = dimap id (\a -> Tuple a a ) id
25
+
You can’t perform that action at this time.
0 commit comments