版博士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.
 
 
 
 

90 lines
2.1 KiB

  1. /**
  2. * ```ts
  3. * interface Separated<E, A> {
  4. * readonly left: E
  5. * readonly right: A
  6. * }
  7. * ```
  8. *
  9. * Represents a result of separating a whole into two parts.
  10. *
  11. * @since 2.10.0
  12. */
  13. import { Functor2 } from './Functor'
  14. import { Bifunctor2 } from './Bifunctor'
  15. /**
  16. * A `Separated` type which holds `left` and `right` parts.
  17. *
  18. * @category model
  19. * @since 2.10.0
  20. */
  21. export interface Separated<E, A> {
  22. readonly left: E
  23. readonly right: A
  24. }
  25. /**
  26. * @category constructors
  27. * @since 2.10.0
  28. */
  29. export declare const separated: <E, A>(left: E, right: A) => Separated<E, A>
  30. /**
  31. * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
  32. * use the type constructor `F` to represent some computational context.
  33. *
  34. * @category mapping
  35. * @since 2.10.0
  36. */
  37. export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Separated<E, A>) => Separated<E, B>
  38. /**
  39. * Map a function over the first type argument of a bifunctor.
  40. *
  41. * @category error handling
  42. * @since 2.10.0
  43. */
  44. export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Separated<E, A>) => Separated<G, A>
  45. /**
  46. * Map a pair of functions over the two type arguments of the bifunctor.
  47. *
  48. * @category mapping
  49. * @since 2.10.0
  50. */
  51. export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Separated<E, A>) => Separated<G, B>
  52. /**
  53. * @category type lambdas
  54. * @since 2.10.0
  55. */
  56. export declare const URI = 'Separated'
  57. /**
  58. * @category type lambdas
  59. * @since 2.10.0
  60. */
  61. export declare type URI = typeof URI
  62. declare module './HKT' {
  63. interface URItoKind2<E, A> {
  64. readonly [URI]: Separated<E, A>
  65. }
  66. }
  67. /**
  68. * @category instances
  69. * @since 2.10.0
  70. */
  71. export declare const Bifunctor: Bifunctor2<URI>
  72. /**
  73. * @category instances
  74. * @since 2.10.0
  75. */
  76. export declare const Functor: Functor2<URI>
  77. /**
  78. * @category mapping
  79. * @since 2.10.0
  80. */
  81. export declare const flap: <A>(a: A) => <E, B>(fab: Separated<E, (a: A) => B>) => Separated<E, B>
  82. /**
  83. * @since 2.10.0
  84. */
  85. export declare const left: <E, A>(s: Separated<E, A>) => E
  86. /**
  87. * @since 2.10.0
  88. */
  89. export declare const right: <E, A>(s: Separated<E, A>) => A