Skip to content

Commit 935f203

Browse files
committed
Add Either specification
1 parent 8099a87 commit 935f203

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,32 @@ The `cata` method takes two arguments:
865865
1. If `f` is not a function, the behaviour of `cata` is unspecified.
866866
2. No parts of `f`'s return value should be checked.
867867

868+
### Either
869+
870+
The `Either` type encodes the concept of binary possibility (Left a and Right b).
871+
872+
```hs
873+
Either a b = { cata :: ((a -> c), (b -> c)) -> c }
874+
left :: a -> Either a b
875+
right :: b -> Either a b
876+
```
877+
878+
A value which conforms to the Either specification must provide an `cata` method.
879+
880+
The `cata` method takes two arguments:
881+
882+
e.cata(f, g)
883+
884+
1. `f` must be a function which returns a value
885+
886+
1. If `f` is not a function, the behaviour of `cata` is unspecified.
887+
2. No parts of `f`'s return value should be checked.
888+
889+
2. `g` must be a function which returns a value
890+
891+
1. If `g` is not a function, the behaviour of `cata` is unspecified.
892+
2. No parts of `g`'s return value should be checked.
893+
868894
## Derivations
869895

870896
When creating data types which satisfy multiple algebras, authors may choose

0 commit comments

Comments
 (0)