Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/state.ts>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 map
import { map } from "https://deno.land/x/fun@v2.0.0-alpha.12/state.ts";

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>