quox/examples/hello.quox

26 lines
779 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)")