Skip to content

Reducer built-ins #143

@ericelliott

Description

@ericelliott

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.

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

Transducer = Reducer => Reducer

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

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

Mappable

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions