Skip to content

Commit

Permalink
add derivation from ‘concat’, ‘of’, ‘zero’, and ‘reduce’
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Jan 3, 2018
1 parent 7dab8da commit 3a341d4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,16 @@ to implement certain methods then derive the remaining methods. Derivations:
}
```

- [`filter`][] may be derived from [`concat`][], [`of`][], [`zero`][], and
[`reduce`][]:

```js
function(pred) {
var F = this.constructor;
return this.reduce((f, x) => pred(x) ? f.concat(F.of(x)) : f, F.zero());
}
```

If a data type provides a method which *could* be derived, its behaviour must
be equivalent to that of the derivation (or derivations).

Expand Down

0 comments on commit 3a341d4

Please sign in to comment.