/** * A (experimental) lazy singly-linked list implementation. Similar to Haskell's `List` */ import type * as HKT from "@principia/prelude/HKT"; import type { Lazy } from "../Function"; /* * ------------------------------------------- * Model * ------------------------------------------- */ export interface Nil { readonly _tag: "Nil"; } export type Cons = { readonly _tag: "Cons"; readonly head: Lazy; readonly tail: Lazy>; }; export type LazyList = Nil | Cons; export const errorEmptyList = (fun: string) => { throw new Error(`List.${fun}: empty list`); }; export type InferListType = T extends LazyList ? A : never; export const URI = "List"; export type URI = typeof URI; export type V = HKT.Auto; declare module "@principia/prelude/HKT" { interface URItoKind { [URI]: LazyList; } }