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

38 lines
678 B

  1. /**
  2. * Mutable references in the `IO` monad
  3. *
  4. * @since 2.0.0
  5. */
  6. import { IO } from './IO'
  7. /**
  8. * @example
  9. * import { io } from 'fp-ts/IO'
  10. * import { newIORef } from 'fp-ts/IORef'
  11. *
  12. * assert.strictEqual(io.chain(newIORef(1), ref => io.chain(ref.write(2), () => ref.read))(), 2)
  13. *
  14. * @category model
  15. * @since 2.0.0
  16. */
  17. export declare class IORef<A> {
  18. private value
  19. /**
  20. * @since 2.0.0
  21. */
  22. readonly read: IO<A>
  23. constructor(value: A)
  24. /**
  25. * @since 2.0.0
  26. */
  27. write(a: A): IO<void>
  28. /**
  29. * @since 2.0.0
  30. */
  31. modify(f: (a: A) => A): IO<void>
  32. }
  33. /**
  34. * @category constructors
  35. * @since 2.0.0
  36. */
  37. export declare function newIORef<A>(a: A): IO<IORef<A>>