lean4-htt/tests/playground/ref2.lean
2019-03-21 15:11:05 -07:00

13 lines
281 B
Text

def initX : IO (IO.ref Nat) :=
IO.mkRef 0
@[init initX] constant x : IO.ref Nat := default _
def inc : IO Unit :=
do v ← x.read,
x.write (v+1),
IO.println (">> " ++ toString v)
def main (xs : List String) : IO Unit :=
do let n := xs.head.toNat,
n.mrepeat (λ _, inc)