Skip to main content
Module

x/fun/mod.ts>array.traverse

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 array.traverse
import { array } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { traverse } = array;

Traverse a ReadonlyArray using an Applicative over V and a mapping function A => V.

Examples

Example 1

import * as A from "./array.ts";
import { pipe, identity } from "./fn.ts";

const traverse = A.traverse(A.ApplicativeArray);

const result = pipe(
  [[1, 2], [3, 4]],
  traverse(identity),
); // [[1, 3], [1, 4], [2, 3], [2, 4]]

Type Parameters

V extends Kind

Parameters

A: Applicative<V>

Returns

<A, I, J = never, K = never, L = unknown, M = unknown>(favi: (a: A, i: number) => $<V, [I, J, K], [L], [M]>) => (ua: ReadonlyArray<A>) => $<V, [ReadonlyArray<I>, J, K], [L], [M]>