Skip to content

Instantly share code, notes, and snippets.

View LiamGoodacre's full-sized avatar
🥩

Liam Goodacre LiamGoodacre

🥩
View GitHub Profile
@LiamGoodacre
LiamGoodacre / Bicat.idr
Last active September 27, 2023 08:32 — forked from zanzix/Bicat.idr
Bicategory constraint issue
-- We define uncurried versions of Pair and Either to help with type-checking
data Tuple : (Type, Type) -> Type where
MkTuple : a -> b -> Tuple (a, b)
data Sum : (Type, Type) -> Type where
Left : a -> Sum (a, b)
Right : b -> Sum (a, b)
-- These are bifunctor versions of projections/injections
data Fst : (Type, Type) -> Type where
@LiamGoodacre
LiamGoodacre / model.ts
Last active February 13, 2022 23:35
TypeScript: flat domain modelling with applicability & invariants
const absurd = (v: never): never => v
const typed = <T,>(v: T): T => v
type Kinded<A extends B, B> = A
type Norm<T> = T extends T ? { [k in keyof T]: T[k] } : never
//
interface Condition { present: unknown; absent: unknown }
type Cond<P, A> = Condition & { present: P, absent: A }
type Not<C extends Condition> = Cond<C['absent'], C['present']>