- concatAll
fold(deprecated)getDualMonoid(deprecated)getEndomorphismMonoid(deprecated)getFunctionMonoid(deprecated)getJoinMonoid(deprecated)getMeetMonoid(deprecated)getStructMonoid(deprecated)getTupleMonoid(deprecated)monoidAll(deprecated)monoidAny(deprecated)monoidProduct(deprecated)monoidString(deprecated)monoidSum(deprecated)monoidVoid(deprecated)- reverse
- struct
- tuple
Get a monoid where concat
will return the maximum, based on the provided bounded order.
The empty
value is the bottom
value.
export declare const max: <A>(B: Bounded<A>) => Monoid<A>
- Added in 0.1.0
import * as N from '@fp-tx/core/number'
import * as M from '@fp-tx/core/Monoid'
const M1 = M.max(N.Bounded)
assert.deepStrictEqual(M1.concat(1, 2), 2)
- MIT – Copyright (c) 2017-present Giulio Canti
Get a monoid where concat
will return the minimum, based on the provided bounded order.
The empty
value is the top
value.
export declare const min: <A>(B: Bounded<A>) => Monoid<A>
- Added in 0.1.0
import * as N from '@fp-tx/core/number'
import * as M from '@fp-tx/core/Monoid'
const M1 = M.min(N.Bounded)
assert.deepStrictEqual(M1.concat(1, 2), 1)
- MIT – Copyright (c) 2017-present Giulio Canti
export interface Monoid<A> extends Se.Semigroup<A> {
readonly empty: 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 monoid empty
value.
export declare const concatAll: <A>(M: Monoid<A>) => (as: readonly A[]) => A
- Added in 0.1.0
import { concatAll } from '@fp-tx/core/Monoid'
import * as N from '@fp-tx/core/number'
assert.deepStrictEqual(concatAll(N.MonoidSum)([1, 2, 3]), 6)
assert.deepStrictEqual(concatAll(N.MonoidSum)([]), 0)
- MIT – Copyright (c) 2017-present Giulio Canti
Use concatAll
instead.
export declare const fold: <A>(M: Monoid<A>) => (as: readonly A[]) => A
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use reverse
instead.
export declare const getDualMonoid: <A>(M: Monoid<A>) => Monoid<A>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use getEndomorphismMonoid
instead.
Note. The execution order in getEndomorphismMonoid
is reversed.
export declare const getEndomorphismMonoid: <A = never>() => Monoid<Endomorphism<A>>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use getMonoid
instead.
export declare const getFunctionMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use max
instead.
export declare const getJoinMonoid: <A>(B: Bounded<A>) => Monoid<A>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use min
instead.
export declare const getMeetMonoid: <A>(B: Bounded<A>) => Monoid<A>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use struct
instead.
export declare const getStructMonoid: <O extends ReadonlyRecord<string, any>>(monoids: {
[K in keyof O]: Monoid<O[K]>
}) => Monoid<O>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use tuple
instead.
export declare const getTupleMonoid: <T extends ReadonlyArray<Monoid<any>>>(
...monoids: T
) => Monoid<{
[K in keyof T]: T[K] extends Se.Semigroup<infer A> ? A : never
}>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use MonoidAll
instead.
export declare const monoidAll: Monoid<boolean>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use MonoidAny
instead.
export declare const monoidAny: Monoid<boolean>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use MonoidProduct
instead.
export declare const monoidProduct: Monoid<number>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use Monoid
instead.
export declare const monoidString: Monoid<string>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use MonoidSum
instead.
export declare const monoidSum: Monoid<number>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
Use Monoid
instead.
export declare const monoidVoid: Monoid<void>
- Added in 0.1.0
- Deprecated
- MIT – Copyright (c) 2017-present Giulio Canti
The dual of a Monoid
, obtained by swapping the arguments of concat
.
export declare const reverse: <A>(M: Monoid<A>) => Monoid<A>
- Added in 0.1.0
import { reverse } from '@fp-tx/core/Monoid'
import * as S from '@fp-tx/core/string'
assert.deepStrictEqual(reverse(S.Monoid).concat('a', 'b'), 'ba')
- MIT – Copyright (c) 2017-present Giulio Canti
Given a struct of monoids returns a monoid for the struct.
export declare const struct: <A>(monoids: { [K in keyof A]: Monoid<A[K]> }) => Monoid<{
readonly [K_1 in keyof A]: A[K_1]
}>
- Added in 0.1.0
import { struct } from '@fp-tx/core/Monoid'
import * as N from '@fp-tx/core/number'
interface Point {
readonly x: number
readonly y: number
}
const M = struct<Point>({
x: N.MonoidSum,
y: N.MonoidSum,
})
assert.deepStrictEqual(M.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })
- MIT – Copyright (c) 2017-present Giulio Canti
Given a tuple of monoids returns a monoid for the tuple.
export declare const tuple: <A extends readonly unknown[]>(
...monoids: { [K in keyof A]: Monoid<A[K]> }
) => Monoid<Readonly<A>>
- Added in 0.1.0
import { tuple } from '@fp-tx/core/Monoid'
import * as B from '@fp-tx/core/boolean'
import * as N from '@fp-tx/core/number'
import * as S from '@fp-tx/core/string'
const M1 = tuple(S.Monoid, N.MonoidSum)
assert.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])
const M2 = tuple(S.Monoid, N.MonoidSum, B.MonoidAll)
assert.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])
- MIT – Copyright (c) 2017-present Giulio Canti