import { head, tail } from "./combinators";
import { cons_, nil } from "./constructors";
import { isEmpty } from "./guards";
import type { LazyList } from "./model";
/*
* -------------------------------------------
* Functor LazyList
* -------------------------------------------
*/
export const map_ = (xs: LazyList, f: (a: A) => B): LazyList =>
isEmpty(xs)
? nil
: cons_(
() => f(head(xs)),
() => map_(tail(xs), f)
);
export const map = (f: (a: A) => B) => (fa: LazyList): LazyList => map_(fa, f);