Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Arnaldi mikearnaldi

View GitHub Profile
View encoding-hkt.ts
export interface None {
readonly _tag: "None"
}
export interface Some<A> {
readonly _tag: "Some"
readonly value: A
}
export type Option<A> = None | Some<A>
View type-variance-in-ts.ts
/**
* Base types
*/
export type X = string;
export type Y = "nominal";
export type Z = string | symbol;
export type Extends<A, B> = [A] extends [B]
? "sub-type"
: [B] extends [A]
@mikearnaldi
mikearnaldi / recursion.ts
Last active Apr 5, 2020
Recursion schemes in TS
View recursion.ts
import { Functor1 } from "fp-ts/lib/Functor";
import { URIS, Kind } from "fp-ts/lib/HKT";
import { pipeable } from "fp-ts/lib/pipeable";
import { flow } from "fp-ts/lib/function";
interface Algebra<F extends URIS, A> {
(_: Kind<F, A>): A;
}
interface Fix<F extends URIS> {