Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

apply

import { apply } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/state.ts";

Apply the A value of State<E, A> to the (a: A) => I value of State<E, (a: A) => I>, producing a State<E, I>.

@example
import * as S from "./state.ts";
import { pipe } from "./fn.ts";

const work = pipe(
  S.id<string>(),
  S.map(s => (n: number) => s.repeat(n)),
  S.apply(S.gets(s => s.length))
);

const result1 = work("Hi"); // ["HiHi", "Hi"]
const result2 = work("Hello");
// ["HelloHelloHelloHelloHello", "Hello"]
function apply<E, A>(ua: State<E, A>): <I>(ufai: State<E, (a: A) => I>) => State<E, I>;
§
apply<E, A>(ua: State<E, A>): <I>(ufai: State<E, (a: A) => I>) => State<E, I>
[src]

§Type Parameters

§Parameters

§
ua: State<E, A>
[src]

§Return Type

§
<I>(ufai: State<E, (a: A) => I>) => State<E, I>
[src]