Created
May 11, 2026 06:40
-
-
Save ronenlh/f4c552a66726675e4eae49438ff4faca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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