Innovenergy_trunk/frontend/node_modules/fp-ts/es6/Semigroup.d.ts

303 lines
7.4 KiB
TypeScript
Raw Normal View History

import * as M from './Magma'
import * as Or from './Ord'
import { ReadonlyRecord } from './ReadonlyRecord'
import Ord = Or.Ord
import Magma = M.Magma
/**
* @category model
* @since 2.0.0
*/
export interface Semigroup<A> extends Magma<A> {}
/**
* Get a semigroup where `concat` will return the minimum, based on the provided order.
*
* @example
* import * as N from 'fp-ts/number'
* import * as S from 'fp-ts/Semigroup'
*
* const S1 = S.min(N.Ord)
*
* assert.deepStrictEqual(S1.concat(1, 2), 1)
*
* @category constructors
* @since 2.10.0
*/
export declare const min: <A>(O: Or.Ord<A>) => Semigroup<A>
/**
* Get a semigroup where `concat` will return the maximum, based on the provided order.
*
* @example
* import * as N from 'fp-ts/number'
* import * as S from 'fp-ts/Semigroup'
*
* const S1 = S.max(N.Ord)
*
* assert.deepStrictEqual(S1.concat(1, 2), 2)
*
* @category constructors
* @since 2.10.0
*/
export declare const max: <A>(O: Or.Ord<A>) => Semigroup<A>
/**
* @category constructors
* @since 2.10.0
*/
export declare const constant: <A>(a: A) => Semigroup<A>
/**
* The dual of a `Semigroup`, obtained by swapping the arguments of `concat`.
*
* @example
* import { reverse } from 'fp-ts/Semigroup'
* import * as S from 'fp-ts/string'
*
* assert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba')
*
* @since 2.10.0
*/
export declare const reverse: <A>(S: Semigroup<A>) => Semigroup<A>
/**
* Given a struct of semigroups returns a semigroup for the struct.
*
* @example
* import { struct } from 'fp-ts/Semigroup'
* import * as N from 'fp-ts/number'
*
* interface Point {
* readonly x: number
* readonly y: number
* }
*
* const S = struct<Point>({
* x: N.SemigroupSum,
* y: N.SemigroupSum
* })
*
* assert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })
*
* @since 2.10.0
*/
export declare const struct: <A>(semigroups: { [K in keyof A]: Semigroup<A[K]> }) => Semigroup<{
readonly [K_1 in keyof A]: A[K_1]
}>
/**
* Given a tuple of semigroups returns a semigroup for the tuple.
*
* @example
* import { tuple } from 'fp-ts/Semigroup'
* import * as B from 'fp-ts/boolean'
* import * as N from 'fp-ts/number'
* import * as S from 'fp-ts/string'
*
* const S1 = tuple(S.Semigroup, N.SemigroupSum)
* assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])
*
* const S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)
* assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])
*
* @since 2.10.0
*/
export declare const tuple: <A extends readonly unknown[]>(
...semigroups: { [K in keyof A]: Semigroup<A[K]> }
) => Semigroup<Readonly<A>>
/**
* Between each pair of elements insert `middle`.
*
* @example
* import { intercalate } from 'fp-ts/Semigroup'
* import * as S from 'fp-ts/string'
* import { pipe } from 'fp-ts/function'
*
* const S1 = pipe(S.Semigroup, intercalate(' + '))
*
* assert.strictEqual(S1.concat('a', 'b'), 'a + b')
*
* @since 2.10.0
*/
export declare const intercalate: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>
/**
* Always return the first argument.
*
* @example
* import * as S from 'fp-ts/Semigroup'
*
* assert.deepStrictEqual(S.first<number>().concat(1, 2), 1)
*
* @category instances
* @since 2.10.0
*/
export declare const first: <A = never>() => Semigroup<A>
/**
* Always return the last argument.
*
* @example
* import * as S from 'fp-ts/Semigroup'
*
* assert.deepStrictEqual(S.last<number>().concat(1, 2), 2)
*
* @category instances
* @since 2.10.0
*/
export declare const last: <A = never>() => Semigroup<A>
/**
* Given a sequence of `as`, concat them and return the total.
*
* If `as` is empty, return the provided `startWith` value.
*
* @example
* import { concatAll } from 'fp-ts/Semigroup'
* import * as N from 'fp-ts/number'
*
* const sum = concatAll(N.SemigroupSum)(0)
*
* assert.deepStrictEqual(sum([1, 2, 3]), 6)
* assert.deepStrictEqual(sum([]), 0)
*
* @since 2.10.0
*/
export declare const concatAll: <A>(S: Semigroup<A>) => (startWith: A) => (as: ReadonlyArray<A>) => A
/**
* Use `void` module instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupVoid: Semigroup<void>
/**
* Use [`getAssignSemigroup`](./struct.ts.html#getAssignSemigroup) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getObjectSemigroup: <A extends object = never>() => Semigroup<A>
/**
* Use [`last`](#last) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getLastSemigroup: <A = never>() => Semigroup<A>
/**
* Use [`first`](#first) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getFirstSemigroup: <A = never>() => Semigroup<A>
/**
* Use [`tuple`](#tuple) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getTupleSemigroup: <T extends ReadonlyArray<Semigroup<any>>>(
...semigroups: T
) => Semigroup<{
[K in keyof T]: T[K] extends Semigroup<infer A> ? A : never
}>
/**
* Use [`struct`](#struct) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getStructSemigroup: <O extends ReadonlyRecord<string, any>>(semigroups: {
[K in keyof O]: Semigroup<O[K]>
}) => Semigroup<O>
/**
* Use [`reverse`](#reverse) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getDualSemigroup: <A>(S: Semigroup<A>) => Semigroup<A>
/**
* Use [`max`](#max) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getJoinSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>
/**
* Use [`min`](#min) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getMeetSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>
/**
* Use [`intercalate`](#intercalate) instead.
*
* @category zone of death
* @since 2.5.0
* @deprecated
*/
export declare const getIntercalateSemigroup: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>
/**
* Use [`concatAll`](#concatall) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare function fold<A>(S: Semigroup<A>): {
(startWith: A): (as: ReadonlyArray<A>) => A
(startWith: A, as: ReadonlyArray<A>): A
}
/**
* Use [`SemigroupAll`](./boolean.ts.html#SemigroupAll) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupAll: Semigroup<boolean>
/**
* Use [`SemigroupAny`](./boolean.ts.html#SemigroupAny) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupAny: Semigroup<boolean>
/**
* Use [`getSemigroup`](./function.ts.html#getSemigroup) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const getFunctionSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S>
/**
* Use [`Semigroup`](./string.ts.html#Semigroup) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupString: Semigroup<string>
/**
* Use [`SemigroupSum`](./number.ts.html#SemigroupSum) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupSum: Semigroup<number>
/**
* Use [`SemigroupProduct`](./number.ts.html#SemigroupProduct) instead.
*
* @category zone of death
* @since 2.0.0
* @deprecated
*/
export declare const semigroupProduct: Semigroup<number>