Overview

The free group generated by elements of A, up to equality. Note that the Setoid and Monoid instances differ from the standard such instances for Array<Either<A, A>>; two elements of the free group are equal iff they are equal after being reduced to “canonical form”, i.e., cancelling adjacent inverses.

Adapted from https://hackage.haskell.org/package/free-algebras-0.0.7.0/docs/Data-Group-Free.html


Table of contents


URI (type alias)

Signature

export type URI = typeof URI

FreeGroup (class)

Signature

export class FreeGroup<A> {
  constructor(readonly value: Array<Either<A, A>>) { ... }
  ...
}

Added in v1.13.0

map (method)

Signature

map<B>(f: (a: A) => B): FreeGroup<B> { ... }

ap (method)

Signature

ap<B>(fab: FreeGroup<(a: A) => B>): FreeGroup<B> { ... }

ap_ (method)

Signature

ap_<B, C>(this: FreeGroup<(b: B) => C>, fb: FreeGroup<B>): FreeGroup<C> { ... }

chain (method)

Signature

chain<B>(f: (a: A) => FreeGroup<B>): FreeGroup<B> { ... }

URI (constant)

Signature

export const URI = ...

empty (constant)

Signature

export const empty: FreeGroup<never> = ...

Added in v1.13.0

freeGroup (constant)

Signature

export const freeGroup: Monad1<URI> = ...

Added in v1.13.0

fromArray (function)

Smart constructor which normalizes an array

Signature

export const fromArray = <A>(S: Setoid<A>): ((as: Array<Either<A, A>>) => FreeGroup<A>) => ...

Added in v1.13.0

getGroup (function)

Signature

export const getGroup = <A>(S: Setoid<A>): Group<FreeGroup<A>> => ...

Added in v1.13.0

getSetoid (function)

Signature

export const getSetoid = <A>(S: Setoid<A>): Setoid<FreeGroup<A>> => ...

Added in v1.13.0

normalize (function)

Reduce a term of a free group to canonical form, i.e. cancelling adjacent inverses.

Signature

export const normalize = <A>(S: Setoid<A>) => (g: Array<Either<A, A>>): Array<Either<A, A>> => ...

Added in v1.13.0