77
88prelude
99public import Init.System.Promise
10- public meta import Lean.Elab.Term
1110
1211public section
1312
@@ -307,21 +306,11 @@ def block (x : AsyncTask α) : IO α :=
307306 | .ok a => return a
308307 | .error e => .error e
309308
310- syntax "currFunctionError%" : term
311-
312- elab_rules : term
313- | `(currFunctionError%) => do
314- let declName? ← Lean.Elab.Term.getDeclName?
315- let fnName := match declName? with
316- | some name => s! "the promise linked to `{ name} ` was dropped"
317- | none => "the promise linked to the Async was dropped"
318- Lean.Elab.Term.elabTerm (← `($(Lean.quote fnName))) none
319-
320309/--
321310Create an `AsyncTask` that resolves to the value of `x`.
322311-/
323312@[inline]
324- def ofPromise (x : IO.Promise (Except IO.Error α)) (error : String := by exact currFunctionError% ) : AsyncTask α :=
313+ def ofPromise (x : IO.Promise (Except IO.Error α)) (error : String := "the promise linked to the Async was dropped" ) : AsyncTask α :=
325314 x.result?.map fun
326315 | none => .error error
327316 | some res => res
@@ -330,7 +319,7 @@ def ofPromise (x : IO.Promise (Except IO.Error α)) (error : String := by exact
330319Create an `AsyncTask` that resolves to the value of `x`.
331320-/
332321@[inline]
333- def ofPurePromise (x : IO.Promise α) (error : String := by exact currFunctionError% ) : AsyncTask α :=
322+ def ofPurePromise (x : IO.Promise α) (error : String := "the promise linked to the Async was dropped" ) : AsyncTask α :=
334323 x.result?.map (sync := true ) fun
335324 | none => .error error
336325 | some res => pure res
@@ -895,7 +884,7 @@ protected def block (x : Async α) (prio := Task.Priority.default) : IO α :=
895884Converts `Promise` into `Async`.
896885-/
897886@[inline]
898- protected def ofPromise (task : IO (IO.Promise (Except IO.Error α))) (error : String := by exact currFunctionError% ) : Async α := do
887+ protected def ofPromise (task : IO (IO.Promise (Except IO.Error α))) (error : String := "the promise linked to the Async was dropped" ) : Async α := do
899888 match ← task.toBaseIO with
900889 | .ok data => pure (f := BaseIO) <| MaybeTask.ofTask <| data.result?.map fun
901890 | none => .error error
@@ -936,7 +925,7 @@ protected def ofTask (task : Task α) : Async α := do
936925Converts `IO (IO.Promise α)` to `Async`.
937926-/
938927@[inline]
939- protected def ofPurePromise (task : IO (IO.Promise α)) (error : String := by exact currFunctionError% ) : Async α := show BaseIO _ from do
928+ protected def ofPurePromise (task : IO (IO.Promise α)) (error : String := "the promise linked to the Async was dropped" ) : Async α := show BaseIO _ from do
940929 match ← task.toBaseIO with
941930 | .ok data => pure <| MaybeTask.ofTask <| data.result?.map fun
942931 | none => .error error
0 commit comments