Copyright | (c) 2009-2015, Peter Trško |
---|---|

License | BSD3 |

Stability | provisional |

Portability | NoImplicitPrelude, RankNTypes |

Safe Haskell | Safe |

Language | Haskell2010 |

Deprecated: Use module Control.Monad.TaggedException.Core instead.

Utility functions built on top of core API.

Functions from this module were moved in to Control.Monad.TaggedException.Core, and this module became deprecated.

For compatibility reasons this module re-exports all functions that were previously defined here, but this module will be removed in the future. Please update your code to use Control.Monad.TaggedException.Core instead.

- bracket :: (Exception e, MonadMask m) => m a -> (a -> m b) -> (a -> Throws e m c) -> Throws e m c
- bracket' :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c
- bracket_ :: (Exception e, MonadMask m) => m a -> m b -> Throws e m c -> Throws e m c
- bracketOnError :: (Exception e, MonadMask m) => m a -> (a -> m b) -> (a -> Throws e m c) -> Throws e m c
- bracketOnError' :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: (Exception e, MonadMask m) => Throws e m a -> m b -> Throws e m a
- finally' :: MonadMask m => m a -> m b -> m a

# Documentation

:: (Exception e, MonadMask m) | |

=> m a | Computation to run before |

-> (a -> m b) | Computation to run after |

-> (a -> Throws e m c) | Computation to run in-between |

-> Throws e m c | Result of the in-between computation |

Run computation surrounded by acquire and release computations. The
release computation is executed even if "in-between" computation
raises exception. See also `bracket'`

, `bracket_`

, `bracketOnError`

,
and `bracketOnError'`

.

:: MonadMask m | |

=> m a | Computation to run before |

-> (a -> m b) | Computation to run after |

-> (a -> m c) | Computation to run in-between |

-> m c | Result of the in-between computation |

Run computation surrounded by acquire and release computations. The
release computation is executed even if "in-between" computation
raises exception. See also `bracket`

, `bracket_`

, `bracketOnError`

, and
`bracketOnError'`

.

Implementated as:

`bracket'`

acq rel go =`mask'`

$ \restore -> do x <- acq r <- restore (go x) ``onException'`

` rel x _ <- rel x return r

:: (Exception e, MonadMask m) | |

=> m a | Computation to run before |

-> (a -> m b) | Computation to run after if an exception was raised |

-> (a -> Throws e m c) | Computation to run in-between |

-> Throws e m c | Result of the in-between computation |

Version of `bracket`

where "after" computation is executed only if
"in-between" computation raises exception.

Implemented as:

`bracketOnError`

acq rel go =`mask`

$ \restore -> do x <-`liftT`

acq restore (go x) ``onException`

` rel x

:: MonadMask m | |

=> m a | Computation to run before |

-> (a -> m b) | Computation to run after if an exception was raised |

-> (a -> m c) | Computation to run in-between |

-> m c | Result of the in-between computation |

Version of `bracket`

where "after" computation is executed only if
"in-between" computation raises exception.

Implemented as:

`bracketOnError'`

acq rel go =`mask'`

$ \restore -> do x <-`liftT`

acq restore (go x) ``onException'`

` rel x

:: (Exception e, MonadMask m) | |

=> Throws e m a | Computation to run first |

-> m b | Computation to run afterward (even if exception |

-> Throws e m a | Returns the result of the first computation |

Run computation afeter another even if exception was thrown. See also
`finally'`

, `onException`

and `onException'`

.

Implemented as:

m ``finally`

` n =`mask`

$ \restore -> do r <- restore m ``onException`

` n _ <-`liftT`

n return r

:: MonadMask m | |

=> m a | Computation to run first |

-> m b | Computation to run afterward (even if some exception was raised) |

-> m a | Returns the result of the first computation |

Run computation afeter another even if exception was thrown. See also
`finally`

, `onException`

and `onException'`

.