Skip to content

Instantly share code, notes, and snippets.

@ronenlh
Created May 11, 2026 06:40
Show Gist options
  • Select an option

  • Save ronenlh/f4c552a66726675e4eae49438ff4faca to your computer and use it in GitHub Desktop.

Select an option

Save ronenlh/f4c552a66726675e4eae49438ff4faca to your computer and use it in GitHub Desktop.
// TypeScript
// Types
type P = { readonly tag: "P" };
type Q = { readonly tag: "Q" };
type R = { readonly tag: "R" };
type Theorem = (h: (p: P) => (q: Q) => R) => ((hpq: { left: P; right: Q }) => R);
// Theorem
const theorem: Theorem = (h) => {
return function (hpq) {
return h(hpq.left)(hpq.right);
};
}
// We could have also used tuple type as well for hpq: [P,Q]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment