This feature produced counterintuitive behavior and confused users. See discussion at #770. As pointed out by @tydeu, it is not too much work to write `Id.run <|` before the `do` when we want to use the `do` notation in pure code. closes #770
16 lines
383 B
Text
16 lines
383 B
Text
def build (n : Nat) : Array Unit := Id.run <| do
|
||
let mut out := #[]
|
||
for _ in [0:n] do
|
||
out := out.push ()
|
||
out
|
||
|
||
@[noinline] def size : IO Nat := pure 50000
|
||
|
||
def bench (f : ∀ {α : Type}, α → IO Unit := fun _ => ()) : IO Unit := do
|
||
let n ← size
|
||
let arr := build n
|
||
timeit "time" $
|
||
for _ in [:1000] do
|
||
f $ #[1, 2, 3, 4].map fun ty => arr[ty]
|
||
|
||
#eval bench
|