export interface Magma<A> {
readonly concat: (x: A, y: A) => A
}
- Added in 0.1.0
- MIT – Copyright (c) 2017-present Giulio Canti
Given a sequence of as
, concat them and return the total.
If as
is empty, return the provided startWith
value.
export declare const concatAll: <A>(M: Magma<A>) => (startWith: A) => (as: readonly A[]) => A
- Added in 0.1.0
import { concatAll } from '@fp-tx/core/Magma'
import * as N from '@fp-tx/core/number'
const subAll = concatAll(N.MagmaSub)(0)
assert.deepStrictEqual(subAll([1, 2, 3]), -6)
- MIT – Copyright (c) 2017-present Giulio Canti
export declare const endo: <A>(f: Endomorphism<A>) => (M: Magma<A>) => Magma<A>
- Added in 0.1.0
- MIT – Copyright (c) 2017-present Giulio Canti
export declare const filterFirst: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>
- Added in 0.1.0
- MIT – Copyright (c) 2017-present Giulio Canti
export declare const filterSecond: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>
- Added in 0.1.0
- MIT – Copyright (c) 2017-present Giulio Canti
The dual of a Magma
, obtained by swapping the arguments of concat
.
export declare const reverse: <A>(M: Magma<A>) => Magma<A>
- Added in 0.1.0
import { reverse, concatAll } from '@fp-tx/core/Magma'
import * as N from '@fp-tx/core/number'
const subAll = concatAll(reverse(N.MagmaSub))(0)
assert.deepStrictEqual(subAll([1, 2, 3]), 2)
- MIT – Copyright (c) 2017-present Giulio Canti