test(tests/playground/ref2): small example using [init]

This commit is contained in:
Leonardo de Moura 2019-03-18 15:52:36 -07:00
parent d5180ffa17
commit 970ebd2b91

View file

@ -0,0 +1,13 @@
def init_x : io (io.ref nat) :=
io.mk_ref 0
@[init init_x] constant x : io.ref nat := default _
def inc : io unit :=
do v ← x.read,
x.write (v+1),
io.println (">> " ++ to_string v)
def main (xs : list string) : io unit :=
do let n := xs.head.to_nat,
n.mrepeat (λ _, inc)