Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell98 |

- 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
- bothResults :: PromiseResult a -> PromiseResult b -> PromiseResult (a, b)

# Promises

A promise

an :: PromiseResult a -> a Source

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 -> Bool Source

Is this a result?

isUnfinished :: PromiseResult a -> Bool Source

Is this unfinished?

isCancelled :: PromiseResult a -> Bool Source

Is this cancelled?

## Combining results

eitherResult :: PromiseResult a -> PromiseResult a -> PromiseResult a Source

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.

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.