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

traverse

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

Traverse a ReadonlySet value by value, applying a function A -> V, then collecting all of the I values into ReadonlySet and returning V<ReadonlySet>. In concrete terms this can take ReadonlySet<Option> and turn it into Option<ReadonlySet> and other ADT inversions.

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

const traverseOption = S.traverse(O.ApplicableOption);
const invert = traverseOption((o: O.Option<number>) => o);

const result1 = pipe(
  S.set(O.some(1), O.some(2), O.some(3)),
  invert,
); // Some(Set(1, 2, 3))
const result2 = pipe(
  S.set(O.some(1), O.some(2), O.none),
  invert,
); // None
function traverse<V extends Kind>(A: Applicable<V>): <A, I, J, K, L, M>(favi: (a: A) => $<V, [I, J, K], [L], [M]>) => (ua: ReadonlySet<A>) => $<V, [ReadonlySet<I>, J, K], [L], [M]>;
§
traverse<V extends Kind>(A: Applicable<V>): <A, I, J, K, L, M>(favi: (a: A) => $<V, [I, J, K], [L], [M]>) => (ua: ReadonlySet<A>) => $<V, [ReadonlySet<I>, J, K], [L], [M]>
[src]

§Type Parameters

§
V extends Kind
[src]

§Parameters

§Return Type

§
<A, I, J, K, L, M>(favi: (a: A) => $<V, [I, J, K], [L], [M]>) => (ua: ReadonlySet<A>) => $<V, [ReadonlySet<I>, J, K], [L], [M]>
[src]