Based on the discussion at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/for.2C.20unexpected.20need.20for.20type.20ascription/near/269083574 The consensus seemed to be that "auto pure" is more confusing than its worth.
23 lines
471 B
Text
23 lines
471 B
Text
def f (x : Nat) : IO Unit := do
|
|
x -- Error
|
|
IO.println x
|
|
|
|
def f' (x : Nat) : IO Unit := do
|
|
discard (pure x)
|
|
IO.println x
|
|
|
|
def g (xs : Array Nat) : IO Unit := do
|
|
xs.set! 0 1 -- Error
|
|
IO.println xs
|
|
|
|
def g' (xs : Array Nat) : IO Unit := do
|
|
discard <| pure (xs.set! 0 1)
|
|
IO.println xs
|
|
|
|
def h (xs : Array Nat) : IO Unit := do
|
|
pure (xs.set! 0 1) -- Error
|
|
IO.println xs
|
|
|
|
def h' (xs : Array Nat) : IO Unit := do
|
|
discard <| pure (xs.set! 0 1)
|
|
IO.println xs
|