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

преди 1 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * This class identifies data structures which can be _unfolded_, generalizing `unfold` on arrays.
  3. *
  4. * @since 2.0.0
  5. */
  6. import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'
  7. import { Option } from './Option'
  8. /**
  9. * @category model
  10. * @since 2.0.0
  11. */
  12. export interface Unfoldable<F> {
  13. readonly URI: F
  14. readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => HKT<F, A>
  15. }
  16. /**
  17. * @category model
  18. * @since 2.0.0
  19. */
  20. export interface Unfoldable1<F extends URIS> {
  21. readonly URI: F
  22. readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind<F, A>
  23. }
  24. /**
  25. * @category model
  26. * @since 2.0.0
  27. */
  28. export interface Unfoldable2<F extends URIS2> {
  29. readonly URI: F
  30. readonly unfold: <E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>
  31. }
  32. /**
  33. * @category model
  34. * @since 2.0.0
  35. */
  36. export interface Unfoldable2C<F extends URIS2, E> {
  37. readonly URI: F
  38. readonly _E: E
  39. readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>
  40. }
  41. /**
  42. * @category model
  43. * @since 2.0.0
  44. */
  45. export interface Unfoldable3<F extends URIS3> {
  46. readonly URI: F
  47. readonly unfold: <R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>
  48. }
  49. /**
  50. * @category model
  51. * @since 2.10.0
  52. */
  53. export interface Unfoldable3C<F extends URIS3, E> {
  54. readonly URI: F
  55. readonly _E: E
  56. readonly unfold: <R, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>
  57. }
  58. /**
  59. * @category model
  60. * @since 2.0.0
  61. */
  62. export interface Unfoldable4<F extends URIS4> {
  63. readonly URI: F
  64. readonly unfold: <S, R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind4<F, S, R, E, A>
  65. }