Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar
Commits
2eb06abf
Commit
2eb06abf
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add MonadFail constraint to MonadAwait
parent
d97a1690
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Quasar/Awaitable.hs
+5
-2
5 additions, 2 deletions
src/Quasar/Awaitable.hs
with
5 additions
and
2 deletions
src/Quasar/Awaitable.hs
+
5
−
2
View file @
2eb06abf
...
@@ -59,7 +59,7 @@ import Data.Sequence
...
@@ -59,7 +59,7 @@ import Data.Sequence
import
Quasar.Prelude
import
Quasar.Prelude
class
(
MonadCatch
m
,
MonadPlus
m
)
=>
MonadAwait
m
where
class
(
MonadCatch
m
,
MonadFail
m
,
MonadPlus
m
)
=>
MonadAwait
m
where
-- | Wait until an awaitable is completed and then return it's value (or throw an exception).
-- | Wait until an awaitable is completed and then return it's value (or throw an exception).
await
::
IsAwaitable
r
a
=>
a
->
m
r
await
::
IsAwaitable
r
a
=>
a
->
m
r
...
@@ -194,7 +194,7 @@ awaitableFromSTM :: forall m a. MonadIO m => STM a -> m (Awaitable a)
...
@@ -194,7 +194,7 @@ awaitableFromSTM :: forall m a. MonadIO m => STM a -> m (Awaitable a)
awaitableFromSTM
transaction
=
cacheAwaitable
(
unsafeAwaitSTM
transaction
::
Awaitable
a
)
awaitableFromSTM
transaction
=
cacheAwaitable
(
unsafeAwaitSTM
transaction
::
Awaitable
a
)
instance
{-# OVERLAPS #-}
(
MonadCatch
m
,
MonadPlus
m
)
=>
MonadAwait
(
ReaderT
(
QueryFn
m
)
m
)
where
instance
{-# OVERLAPS #-}
(
MonadCatch
m
,
MonadFail
m
,
MonadPlus
m
)
=>
MonadAwait
(
ReaderT
(
QueryFn
m
)
m
)
where
await
=
runAwaitable
await
=
runAwaitable
unsafeAwaitSTM
transaction
=
do
unsafeAwaitSTM
transaction
=
do
QueryFn
querySTMFn
<-
ask
QueryFn
querySTMFn
<-
ask
...
@@ -271,6 +271,9 @@ instance MonadCatch AwaitableStepM where
...
@@ -271,6 +271,9 @@ instance MonadCatch AwaitableStepM where
catch
result
@
(
AwaitableFailed
ex
)
handler
=
maybe
result
handler
$
fromException
ex
catch
result
@
(
AwaitableFailed
ex
)
handler
=
maybe
result
handler
$
fromException
ex
catch
(
AwaitableStep
query
next
)
handler
=
AwaitableStep
query
(
\
x
->
next
x
`
catch
`
handler
)
catch
(
AwaitableStep
query
next
)
handler
=
AwaitableStep
query
(
\
x
->
next
x
`
catch
`
handler
)
instance
MonadFail
AwaitableStepM
where
fail
=
throwM
.
userError
instance
Alternative
AwaitableStepM
where
instance
Alternative
AwaitableStepM
where
x
<|>
y
=
x
`
catchAll
`
const
y
x
<|>
y
=
x
`
catchAll
`
const
y
empty
=
throwM
$
toException
$
userError
"empty"
empty
=
throwM
$
toException
$
userError
"empty"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment