Skip to content

Instantly share code, notes, and snippets.

View Walexander's full-sized avatar

Will Alexander Walexander

  • MCO
  • Tysons Corner, VA
View GitHub Profile
@Walexander
Walexander / listr.ts
Created September 11, 2022 18:40
Recursion Schemes For Dynamic Programming: TS-Plus Edition
import type * as P from "@tsplus/stdlib/prelude/Covariant"
import type { Unfolder } from "@tsplus/stdlib/prelude/Recursive"
// Type definitions
export type MyNonEmptyList<A> = Leaf<A> | Node<A>
export type Carrier<A> = Tuple<[A, A]>
export interface ListF extends HKT {
readonly type: MyNonEmptyList<this["A"]>
}
export const Functor: Covariant<ListF> = HKT.instance<P.Covariant<ListF>>({