Skip to main content
Module

x/careful/mod.ts>IO

Safe containerization of values for TypeScript
Latest
class IO
extends Container<Effect<A>>
import { IO } from "https://deno.land/x/careful@v0.1.0/mod.ts";

The IO class represents a lazy computation that may produce a value of type A. It is essentially a wrapper around a function of type () => A, which is called the "effect".

Examples

const getDate = () => new Date().toString(); const dateIO = IO.of(getDate); const upperIO = dateIO.map((date) => date.toUpperCase()); console.log(dateIO.execute()); // -> Output: "Sat Feb 27 2023 11:05:39 GMT-0800 (Pacific Standard Time)"

Constructors

new
IO(effect: Effect<A>, trackId?: NullOr<string>)

Methods

fmap<B>(f: (val: A) => IO<B>): IO<B>
map<B>(f: (val: A) => B): IO<B>

Static Methods

of<T>(val: T)