版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * @since 2.0.0
  3. */
  4. import { Comonad2 } from './Comonad'
  5. import { Endomorphism } from './Endomorphism'
  6. import { Functor as FunctorHKT, Functor1, Functor2, Functor2C, Functor3, Functor3C } from './Functor'
  7. import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'
  8. /**
  9. * @category model
  10. * @since 2.0.0
  11. */
  12. export interface Store<S, A> {
  13. readonly peek: (s: S) => A
  14. readonly pos: S
  15. }
  16. /**
  17. * Reposition the focus at the specified position
  18. *
  19. * @since 2.0.0
  20. */
  21. export declare function seek<S>(s: S): <A>(wa: Store<S, A>) => Store<S, A>
  22. /**
  23. * Reposition the focus at the specified position, which depends on the current position
  24. *
  25. * @since 2.0.0
  26. */
  27. export declare function seeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => Store<S, A>
  28. /**
  29. * Extract a value from a position which depends on the current position
  30. *
  31. * @since 2.0.0
  32. */
  33. export declare function peeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => A
  34. /**
  35. * Extract a collection of values from positions which depend on the current position
  36. *
  37. * @since 2.0.0
  38. */
  39. export declare function experiment<F extends URIS3>(
  40. F: Functor3<F>
  41. ): <R, E, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>
  42. export declare function experiment<F extends URIS3, E>(
  43. F: Functor3C<F, E>
  44. ): <R, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>
  45. export declare function experiment<F extends URIS2>(
  46. F: Functor2<F>
  47. ): <E, S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>
  48. export declare function experiment<F extends URIS2, E>(
  49. F: Functor2C<F, E>
  50. ): <S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>
  51. export declare function experiment<F extends URIS>(
  52. F: Functor1<F>
  53. ): <S>(f: (s: S) => Kind<F, S>) => <A>(wa: Store<S, A>) => Kind<F, A>
  54. export declare function experiment<F>(
  55. F: FunctorHKT<F>
  56. ): <S>(f: (s: S) => HKT<F, S>) => <A>(wa: Store<S, A>) => HKT<F, A>
  57. /**
  58. * @since 2.0.0
  59. */
  60. export declare const extend: <E, A, B>(f: (wa: Store<E, A>) => B) => (wa: Store<E, A>) => Store<E, B>
  61. /**
  62. * @category Extract
  63. * @since 2.6.2
  64. */
  65. export declare const extract: <E, A>(wa: Store<E, A>) => A
  66. /**
  67. * @since 2.0.0
  68. */
  69. export declare const duplicate: <E, A>(wa: Store<E, A>) => Store<E, Store<E, A>>
  70. /**
  71. * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
  72. * use the type constructor `F` to represent some computational context.
  73. *
  74. * @category mapping
  75. * @since 2.0.0
  76. */
  77. export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Store<E, A>) => Store<E, B>
  78. /**
  79. * @category type lambdas
  80. * @since 2.0.0
  81. */
  82. export declare const URI = 'Store'
  83. /**
  84. * @category type lambdas
  85. * @since 2.0.0
  86. */
  87. export declare type URI = typeof URI
  88. declare module './HKT' {
  89. interface URItoKind2<E, A> {
  90. readonly [URI]: Store<E, A>
  91. }
  92. }
  93. /**
  94. * @category instances
  95. * @since 2.7.0
  96. */
  97. export declare const Functor: Functor2<URI>
  98. /**
  99. * @category mapping
  100. * @since 2.10.0
  101. */
  102. export declare const flap: <A>(a: A) => <E, B>(fab: Store<E, (a: A) => B>) => Store<E, B>
  103. /**
  104. * @category instances
  105. * @since 2.7.0
  106. */
  107. export declare const Comonad: Comonad2<URI>
  108. /**
  109. * This instance is deprecated, use small, specific instances instead.
  110. * For example if a function needs a `Comonad` instance, pass `S.Comonad` instead of `S.store`
  111. * (where `S` is from `import S from 'fp-ts/Store'`)
  112. *
  113. * @category zone of death
  114. * @since 2.0.0
  115. * @deprecated
  116. */
  117. export declare const store: Comonad2<URI>