Skip to content

Instantly share code, notes, and snippets.

@L-as
Created July 2, 2025 18:33
Show Gist options
  • Save L-as/13edbab4e25dbe6b6ae9de4d7d14daba to your computer and use it in GitHub Desktop.
Save L-as/13edbab4e25dbe6b6ae9de4d7d14daba to your computer and use it in GitHub Desktop.
(+) : Type -> Type -> Type
a + b = Either a b
record Iso (a : Type) (b : Type) where
constructor MkIso
to : a -> b
from : b -> a
leftInv : (x : a) -> from (to x) = x
rightInv : (y : b) -> to (from y) = y
data (-) : Type -> Type -> Type where
MkSub : (0 iso : Iso (c + b) a) -> c -> a - b
(*) : Type -> Type -> Type
x * y = (x, y)
data (/) : Type -> Type -> Type where
MkDiv : (0 iso : Iso (c * b) a) -> c -> a / b
data Log : Type -> Type -> Type where
MkLog : (0 iso : Iso (exponent -> base) a) -> exponent -> Log base a
log = Log
data Fin : Nat -> Type where
FZ : Fin (S n)
FS : Fin n -> Fin (S n)
example : Fin 10 / Fin 5
example = MkDiv iso (FS FZ) where
0 iso : Iso (Fin 2 * Fin 5) (Fin 10)
-- implementation left as exercise to the reader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment