Overview

Mutable references in the IO monad


Table of contents


IORef (class)

Signature

export class IORef<A> {
  constructor(private value: A) { ... }
  ...
}

Example

import { io } from 'fp-ts/lib/IO'
import { newIORef } from 'fp-ts/lib/IORef'

assert.strictEqual(io.chain(newIORef(1), ref => io.chain(ref.write(2), () => ref.read))(), 2)

Added in v2.0.0

write (method)

Signature

write(a: A): IO<void> { ... }

Added in v2.0.0

modify (method)

Signature

modify(f: (a: A) => A): IO<void> { ... }

Added in v2.0.0

newIORef (function)

Signature

export function newIORef<A>(a: A): IO<IORef<A>> { ... }

Added in v2.0.0