--- title: quox. the language date: 2023-10-25 tags: [quox, computer, types] bibliography: quox.bib link-citations: true show-toc: true ... :::{.aside .floating} ### [hot minute](https://en.wiktionary.org/wiki/hot_minute) n. {.unnumbered} 1. A long period of time. 2. A short period of time. 3. An unspecified period of time. ::: for the last _hot minute_ [@hotminute], i’ve been working on a little programming language. it’s finally starting to approach a state where it can compile some programs, so maybe i should talk about it a bit. # what is a quox [(tl;dr for type system nerds)]{.note}
a dragon from an old arcade game
this is also a quox.
0. it’s a *dependently typed functional language*, like your agdas and your idrises. 1. it has a *closed type universe*. you don’t define new datatypes, but the language gives you building blocks to put them together. 2. *[q]{.qtt-q}uantitative type theory* (qtt) [@nuttin; @qtt] is a nice combination of dependent types, resource tracking, and erasure of stuff like proofs. 3. *[x]{.xtt-x}tt* [@xtt], which `*i sure hope i remember to come back and add this!*` - the closed type universe is a consequence of xtt (as well as its kinda-predecessor ott [@ott-now]), but i decided to just run with it. - “xtt” stands for “extensional type theory”, but it’s not _that_ extensional type theory. i know. not my fault. so now you can see where the name [q]{.qtt-q}uo[x]{.xtt-x} comes from. other than my favourite dragon. anyway it also has
one of my fursonas is a quox with three heads
sometimes i am also a quox. or three, depending on how you count.
4. *bidirectional type checking* [@bidi] `*this one too*` 5. crude-but-effective stratification [@crude; @crude-blog] for dealing with universes. `*does this need more detail too?*` 6. *written in idris2*. that doesn’t really have much impact on the language itself, other than the compilation process, but i’m enjoying using a dependently typed language for something substantial. even if it’s one you’re not currently supposed to be using for anything substantial. also currently it spits out scheme, like idris, because that was easy. 7. all the non-ascii syntax is [optional], but i like it. [optional]: https://git.rhiannon.website/rhi/quox/wiki/ascii-syntax as for what it _doesn’t_ have: any but the most basic of conveniences. sorry. # dependent types there are lots of languages with dependent types—well, quite a few—so i won’t spend too much time on this. `*but still something*` # closed type universe instead of having datatypes like in normal languages, in quox you get the basic building blocks to make them. the main building blocks are functions, pairs, enumerations, equality types, strings, and natural numbers. some sort of syntactic sugar to expand a datatype declaration into this representation _is_ something i want to add, but it'd be in the pretty distant future. :::aside _at the moment_, natural numbers are the only recursion possible. so you can define types with the same recursive structure, like lists, but binary trees and stuff are not _currently_ possible, until i replace them with something more general. probably w-types [@nlab-wtype]. ::: but right now you can define a few types like this. see [qtt](#qtt) below for what all the `0`s and `ω`s mean. due to the lack of generic recursion, but the presence of _natural numbers_ specifically, a list is a length, followed by a nested tuple of that length (terminated by `'nil`). ```quox def0 Vec : ℕ → ★ → ★ = λ n A ⇒ case n return ★ of { zero ⇒ {nil}; succ p, As ⇒ A × As } -- ↖ As = Vec p A def0 List : ★ → ★ = λ A ⇒ (n : ℕ) × Vec n A def Nil : 0.(A : ★) → List A = λ A ⇒ (0, 'nil) def Cons : 0.(A : ★) → A → List A → List A = λ A x xs ⇒ case xs return List A of { (len, xs) ⇒ (succ len, x, xs) } def NilS = Nil String def ConsS = Cons String def example = ConsS "im" (ConsS "gay" NilS) def0 example-eq : example ≡ (2, "im", "gay", 'nil) : List String = refl (List String) example ``` you might have noticed that i didn't write the eliminator. that is because they are kind of ugly. if you want to see it anyway you can find it in [the example folder][ex]. [ex]: https://git.rhiannon.website/rhi/quox/src/commit/246d80eea2/examples/list.quox#L12-L25 # qtt sometimes, values of some type can only be used in certain ways to make sense. this is hardly controversial; if you do this with a problem that dependent types used to have a lot is that the blurring of compile-time and run-time data can lead to more being retained than necessary. `*is there an example that has superlinear junk data without resorting to peano naturals or some shit*` consider this vector (length-indexed list) definition from a _hypothetical language_ with normal inductive types. ```agda data Vect (A : ★) : ℕ → ★ where [] : Vect A 0 _∷_ : (n : ℕ) → A → Vect A n → Vect A (succ n) ``` in a totally naive implementation, `cons` would store `n`, the length of its tail (and maybe even some kind of representation of `A` too). so a three element list would look something like # xtt `*mention about type-case and the closed universe*` # bidirectional type checking # references {#refs}