ericelliott / ericelliott/rtype

Reducer built-ins

Open
#143 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
38
PR merge metrics
No merged PRs in 30d

Description

I use reducers all the time, and frequently use type parameters in documentation named "reducer", and "foldable". It would probably be a good idea to formally define them.

```js
interface Reducible {
reduce?: ((a?, c?, i: Number, Foldable) => a, initial: Any) => Any
}

interface Foldable = Reducible | Iterable

interface Reducer = (a?, c?, i: Number, Foldable) => a
```

### Example

```js
Transducer = Reducer => Reducer

createTransducer = ({
step: Reducer,
init?: Reducer,
result?: Reducer,
next?: Reducer
}) => Reducer => Reducer

transduce = (Reducer, initial: Any, xform: Transducer, Foldable) => Any
```

## Mappable

```js
interface Mappable {
map: Functor(a) ~> (a => b) => Functor(b)
}
```

## Change IterableObject to Iterable

I know it's a breaking change, but AFAIK, there's not a lot of software relying on this, yet.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.