Skip to content

Commit

Permalink
Add Tuple specification
Browse files Browse the repository at this point in the history
  • Loading branch information
gabejohnson committed Jan 12, 2018
1 parent 935f203 commit 15281ac
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ nothing :: Maybe a
just :: a -> Maybe a
```

A value which conforms to the Maybe specification must provide an `cata` method.
A value which conforms to the Maybe specification must provide a `cata` method.

The `cata` method takes two arguments:

Expand All @@ -875,7 +875,7 @@ left :: a -> Either a b
right :: b -> Either a b
```

A value which conforms to the Either specification must provide an `cata` method.
A value which conforms to the Either specification must provide a `cata` method.

The `cata` method takes two arguments:

Expand All @@ -891,6 +891,27 @@ The `cata` method takes two arguments:
1. If `g` is not a function, the behaviour of `cata` is unspecified.
2. No parts of `g`'s return value should be checked.

### Tuple

`Tuple` is the canonical product type and represents a structure containing two
values (Tuple a b).

```hs
Tuple a b = { cata :: ((a, b) -> c) -> c }
tuple :: (a, b) -> Tuple a b
```

A value which conforms to the Tuple specification must provide a `cata` method.

The `cata` method takes a single argument:

t.cata(f)

1. `f` must be a function of two arguments which returns a value

1. If `f` is not a function, the behaviour of `cata` is unspecified.
2. No parts of `f`'s return value should be checked.

## Derivations

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

0 comments on commit 15281ac

Please sign in to comment.