Safe Haskell | Safe-Inferred |
---|
- data Promise a = Promise {}
- an :: PromiseResult a -> a
- data PromiseResult a
- = Unfinished
- | Cancelled
- | An a
- isAn :: PromiseResult a -> Bool
- isUnfinished :: PromiseResult a -> Bool
- isCancelled :: PromiseResult a -> Bool
- eitherResult :: PromiseResult a -> PromiseResult a -> PromiseResult a
- eitherResult' :: Monoid a => (a -> Bool) -> PromiseResult a -> PromiseResult a -> PromiseResult a
- bothResults :: PromiseResult a -> PromiseResult b -> PromiseResult (a, b)
- bothResults' :: Monoid a => (a -> Bool) -> PromiseResult a -> PromiseResult a -> PromiseResult a
Promises
A promise
an :: PromiseResult a -> aSource
Gets the result (partial function)
Results
data PromiseResult a Source
The result of the promise
Unfinished | Not finished yet (or not even spawned yet)) |
Cancelled | Cancelled |
An a | A result |
Functor PromiseResult | |
Eq a => Eq (PromiseResult a) | |
Ord a => Ord (PromiseResult a) | |
Show a => Show (PromiseResult a) |
Querying results
isAn :: PromiseResult a -> BoolSource
Is this a result?
isUnfinished :: PromiseResult a -> BoolSource
Is this unfinished?
isCancelled :: PromiseResult a -> BoolSource
Is this cancelled?
Combining results
eitherResult :: PromiseResult a -> PromiseResult a -> PromiseResult aSource
If either is finished (An
), return one of them (favor the first one)
If either is Unfinished
, this is also Unfinished
.
Otherwise, both are Cancelled
and so is this.
eitherResult' :: Monoid a => (a -> Bool) -> PromiseResult a -> PromiseResult a -> PromiseResult aSource
As eitherResult
, but upon only one returned failure, waits for the other, and then
either mappend
s the results or returns the failure if it is Cancelled
.
mempty
is not used.
bothResults :: PromiseResult a -> PromiseResult b -> PromiseResult (a, b)Source
If both are finished (An
), return them in a tuple.
If either is Cancelled
, this is also Cancelled
.
Otherwise, both are Unfinished
and so is this.
bothResults' :: Monoid a => (a -> Bool) -> PromiseResult a -> PromiseResult a -> PromiseResult aSource
Prefers to return failures than Cancelled
mempty
is not used.