import * as A from "../Array"; import type { Tree } from "./model"; /* * ------------------------------------------- * Applicative Tree * ------------------------------------------- */ export const both_ = (fa: Tree, fb: Tree): Tree => ({ value: [fa.value, fb.value], forest: A.comprehension([fa.forest, fb.forest], (a, b) => both_(a, b)) }); export const both = (fb: Tree) => (fa: Tree): Tree => both_(fa, fb); export const pure = (a: A): Tree => ({ value: a, forest: A.empty() });