Skip to content

Commit

Permalink
chore: intermediate
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Jan 5, 2025
1 parent 7109127 commit 2272faa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/Std/Internal/Async/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ def block (x : AsyncTask α) : IO α := do
Create an `AsyncTask` that resolves to the value of `x`.
-/
@[inline]
def ofPromise (x : IO.Promise α) : AsyncTask α :=
def ofPromise (x : IO.Promise (Except IO.Error α)) : AsyncTask α :=
x.result

/--
Create an `AsyncTask` that resolves to the value of `x`.
-/
@[inline]
def ofPurePromise (x : IO.Promise α) : AsyncTask α :=
x.result.map pure

/--
Expand Down
4 changes: 2 additions & 2 deletions src/Std/Internal/Async/Timer.lean
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If:
@[inline]
def wait (s : Sleep) : IO (AsyncTask Unit) := do
let promise ← s.native.next
return .ofPromise promise
return .ofPurePromise promise

/--
If:
Expand Down Expand Up @@ -108,7 +108,7 @@ If:
@[inline]
def tick (i : Interval) : IO (AsyncTask Unit) := do
let promise ← i.native.next
return .ofPromise promise
return .ofPurePromise promise

/--
If:
Expand Down

0 comments on commit 2272faa

Please sign in to comment.