add hello.quox to examples

This commit is contained in:
rhiannon morris 2023-11-03 17:42:59 +01:00
parent b7e1f37b5b
commit d4639a35c6
1 changed files with 26 additions and 0 deletions

26
examples/hello.quox Normal file
View File

@ -0,0 +1,26 @@
def0 Unit : ★ = {tt}
def drop-unit : 0.(A : ★) → Unit → A → A =
λ A u x ⇒ case u return A of {'tt ⇒ x}
-- postulate0 IOState : ★
def0 IO : ★ → ★ = λ A ⇒ IOState → A × IOState
def bind : 0.(A B : ★) → IO A → (A → IO B) → IO B =
λ A B m k s0 ⇒
case m s0 return B × IOState of { (x, s1) ⇒ k x s1 }
def seq : IO Unit → IO Unit → IO Unit =
λ a b ⇒ bind Unit Unit a (λ u ⇒ drop-unit (IO Unit) u b)
#[compile-scheme "(lambda (n) (builtin-io (display n) (newline) 'tt))"]
postulate print- : → IO Unit
#[compile-scheme "(lambda (str) (builtin-io (display str) (newline) 'tt))"]
postulate print : String → IO Unit
load "nat.quox"
#[main]
def main = seq (print- (nat.plus 1000000000 1)) (print "(nice)")