Skip to content

Commit 933a71c

Browse files
committed
Merge pull request #13 from zrho/master
New classes: Closed, Costrong and Cochoice
2 parents 862bde8 + e562587 commit 933a71c

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

docs/Data/Profunctor/Closed.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Module Data.Profunctor.Closed
2+
3+
#### `Closed`
4+
5+
``` purescript
6+
class (Profunctor p) <= Closed p where
7+
closed :: forall a b x. p a b -> p (x -> a) (x -> b)
8+
```
9+
10+
The `Closed` class extends the `Profunctor` class to work with functions.
11+
12+
##### Instances
13+
``` purescript
14+
instance closedFunction :: Closed Function
15+
```
16+
17+

docs/Data/Profunctor/Cochoice.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Module Data.Profunctor.Cochoice
2+
3+
#### `Cochoice`
4+
5+
``` purescript
6+
class (Profunctor p) <= Cochoice p where
7+
unleft :: forall a b c. p (Either a c) (Either b c) -> p a b
8+
unright :: forall a b c. p (Either a b) (Either a c) -> p b c
9+
```
10+
11+
The `Cochoice` class provides the dual operations of the `Choice` class.
12+
13+

docs/Data/Profunctor/Costrong.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Module Data.Profunctor.Costrong
2+
3+
#### `Costrong`
4+
5+
``` purescript
6+
class (Profunctor p) <= Costrong p where
7+
unfirst :: forall a b c. p (Tuple a c) (Tuple b c) -> p a b
8+
unsecond :: forall a b c. p (Tuple a b) (Tuple a c) -> p b c
9+
```
10+
11+
The `Costrong` class provides the dual operations of the `Strong` class.
12+
13+

src/Data/Profunctor/Closed.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Data.Profunctor.Closed where
2+
3+
import Prelude
4+
5+
import Data.Profunctor
6+
7+
-- | The `Closed` class extends the `Profunctor` class to work with functions.
8+
class (Profunctor p) <= Closed p where
9+
closed :: forall a b x. p a b -> p (x -> a) (x -> b)
10+
11+
instance closedFunction :: Closed Function where
12+
closed = (<<<)

src/Data/Profunctor/Cochoice.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Data.Profunctor.Cochoice where
2+
3+
import Prelude
4+
5+
import Data.Either (Either ())
6+
import Data.Profunctor
7+
8+
-- | The `Cochoice` class provides the dual operations of the `Choice` class.
9+
class (Profunctor p) <= Cochoice p where
10+
unleft :: forall a b c. p (Either a c) (Either b c) -> p a b
11+
unright :: forall a b c. p (Either a b) (Either a c) -> p b c

src/Data/Profunctor/Costrong.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Data.Profunctor.Costrong where
2+
3+
import Prelude
4+
5+
import Data.Tuple (Tuple ())
6+
import Data.Profunctor
7+
8+
-- | The `Costrong` class provides the dual operations of the `Strong` class.
9+
class (Profunctor p) <= Costrong p where
10+
unfirst :: forall a b c. p (Tuple a c) (Tuple b c) -> p a b
11+
unsecond :: forall a b c. p (Tuple a b) (Tuple a c) -> p b c

0 commit comments

Comments
 (0)