版博士V2.0程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

Magma.d.ts 1.5 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * A `Magma` is a pair `(A, concat)` in which `A` is a non-empty set and `concat` is a binary operation on `A`
  3. *
  4. * See [Semigroup](https://gcanti.github.io/fp-ts/modules/Semigroup.ts.html) for some instances.
  5. *
  6. * @since 2.0.0
  7. */
  8. import { Endomorphism } from './Endomorphism'
  9. import { Predicate } from './Predicate'
  10. /**
  11. * @category model
  12. * @since 2.0.0
  13. */
  14. export interface Magma<A> {
  15. readonly concat: (x: A, y: A) => A
  16. }
  17. /**
  18. * The dual of a `Magma`, obtained by swapping the arguments of `concat`.
  19. *
  20. * @example
  21. * import { reverse, concatAll } from 'fp-ts/Magma'
  22. * import * as N from 'fp-ts/number'
  23. *
  24. * const subAll = concatAll(reverse(N.MagmaSub))(0)
  25. *
  26. * assert.deepStrictEqual(subAll([1, 2, 3]), 2)
  27. *
  28. * @since 2.11.0
  29. */
  30. export declare const reverse: <A>(M: Magma<A>) => Magma<A>
  31. /**
  32. * @since 2.11.0
  33. */
  34. export declare const filterFirst: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>
  35. /**
  36. * @since 2.11.0
  37. */
  38. export declare const filterSecond: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>
  39. /**
  40. * @since 2.11.0
  41. */
  42. export declare const endo: <A>(f: Endomorphism<A>) => (M: Magma<A>) => Magma<A>
  43. /**
  44. * Given a sequence of `as`, concat them and return the total.
  45. *
  46. * If `as` is empty, return the provided `startWith` value.
  47. *
  48. * @example
  49. * import { concatAll } from 'fp-ts/Magma'
  50. * import * as N from 'fp-ts/number'
  51. *
  52. * const subAll = concatAll(N.MagmaSub)(0)
  53. *
  54. * assert.deepStrictEqual(subAll([1, 2, 3]), -6)
  55. *
  56. * @since 2.11.0
  57. */
  58. export declare const concatAll: <A>(M: Magma<A>) => (startWith: A) => (as: readonly A[]) => A