Copyright | © Anders Kaseorg 2010 |
---|---|

License | BSD-style |

Maintainer | Anders Kaseorg <andersk@mit.edu> |

Stability | experimental |

Portability | non-portable (extended exceptions) |

Safe Haskell | Safe |

Language | Haskell98 |

This is a wrapped version of Control.Exception with types generalized
from `IO`

to all monads in `MonadPeelIO`

.

- module Control.Exception.Extensible
- throwIO :: (MonadIO m, Exception e) => e -> m a
- ioError :: MonadIO m => IOError -> m a
- catch :: (MonadPeelIO m, Exception e) => m a -> (e -> m a) -> m a
- catches :: MonadPeelIO m => m a -> [Handler m a] -> m a
- data Handler m a = Exception e => Handler (e -> m a)
- catchJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
- handle :: (MonadPeelIO m, Exception e) => (e -> m a) -> m a -> m a
- handleJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a
- try :: (MonadPeelIO m, Exception e) => m a -> m (Either e a)
- tryJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
- evaluate :: MonadIO m => a -> m a
- bracket :: MonadPeelIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- bracket_ :: MonadPeelIO m => m a -> m b -> m c -> m c
- bracketOnError :: MonadPeelIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: MonadPeelIO m => m a -> m b -> m a
- onException :: MonadPeelIO m => m a -> m b -> m a

# Documentation

module Control.Exception.Extensible

:: (MonadPeelIO m, Exception e) | |

=> m a | The computation to run |

-> (e -> m a) | Handler to invoke if an exception is raised |

-> m a |

Generalized version of `catch`

.

:: (MonadPeelIO m, Exception e) | |

=> (e -> Maybe b) | Predicate to select exceptions |

-> m a | Computation to run |

-> (b -> m a) | Handler |

-> m a |

Generalized version of `catchJust`

.

handle :: (MonadPeelIO m, Exception e) => (e -> m a) -> m a -> m a Source #

Generalized version of `handle`

.

handleJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a Source #

Generalized version of `handleJust`

.

tryJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) Source #

Generalized version of `tryJust`

.

:: MonadPeelIO m | |

=> m a | computation to run first ("acquire resource") |

-> (a -> m b) | computation to run last ("release resource") |

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

-> m c |

Generalized version of `bracket`

. Note, any monadic side
effects in `m`

of the "release" computation will be discarded; it
is run only for its side effects in `IO`

.

bracket_ :: MonadPeelIO m => m a -> m b -> m c -> m c Source #

:: MonadPeelIO m | |

=> m a | computation to run first ("acquire resource") |

-> (a -> m b) | computation to run last ("release resource") |

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

-> m c |

Generalized version of `bracketOnError`

.

:: MonadPeelIO m | |

=> m a | computation to run first |

-> m b | computation to run afterward (even if an exception was raised) |

-> m a |

Generalized version of `finally`

. Note, any monadic side
effects in `m`

of the "afterward" computation will be discarded.

onException :: MonadPeelIO m => m a -> m b -> m a Source #

Generalized version of `onException`

.