Skip to main content
Module

x/fun/mod.ts>state.map

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function state.map
import { state } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { map } = state;

Map over the covariant value A in State<E, A>.

Examples

Example 1

import * as S from "./state.ts";
import * as A from "./array.ts";
import { pipe } from "./fn.ts";

const work = pipe(
  S.id<number>(),
  S.map(n => A.range(n)),
);

const result1 = work(1); // [[0], 1]
const result2 = work(3); // [[0, 1, 2], 3]

Parameters

fai: (a: A) => I

Returns

<B>(ta: State<B, A>) => State<B, I>