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

License | BSD-style |

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

Stability | experimental |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell98 |

This module defines the class `MonadPeelIO`

of `IO`

-based monads into
which control operations on `IO`

(such as exception catching; see
Control.Exception.Peel) can be lifted.

`liftIOOp`

and `liftIOOp_`

enable convenient lifting of two common
special cases of control operation types.

- class MonadIO m => MonadPeelIO m where
- liftIOOp :: MonadPeelIO m => ((a -> IO (m b)) -> IO (m c)) -> (a -> m b) -> m c
- liftIOOp_ :: MonadPeelIO m => (IO (m a) -> IO (m b)) -> m a -> m b

# Documentation

class MonadIO m => MonadPeelIO m where Source #

`MonadPeelIO`

is the class of `IO`

-based monads supporting an
extra operation `peelIO`

, enabling control operations on `IO`

to be
lifted into the monad.

peelIO :: m (m a -> IO (m a)) Source #

`peelIO`

is a version of `peel`

that operates through an
arbitrary stack of monad transformers directly to an inner `IO`

(analagously to how `liftIO`

is a version of `lift`

). So it can
be used with `liftIO`

to lift control operations on `IO`

into any
monad in `MonadPeelIO`

. For example:

foo ::`IO`

a ->`IO`

a foo' ::`MonadPeelIO`

m => m a -> m a foo' a = do k <-`peelIO`

-- k :: m a -> IO (m a)`join`

$`liftIO`

$ foo (k a) -- uses foo ::`IO`

(m a) ->`IO`

(m a)

Note that the "obvious" term of this type (`peelIO = `

) `return`

`return`

*does not* work correctly. Instances of `MonadPeelIO`

should be constructed via `MonadTransPeel`

, using ```
peelIO =
```

.`liftPeel`

peelIO

MonadPeelIO IO Source # | |

MonadPeelIO m => MonadPeelIO (MaybeT m) Source # | |

MonadPeelIO m => MonadPeelIO (ListT m) Source # | |

(Monoid w, MonadPeelIO m) => MonadPeelIO (WriterT w m) Source # | |

(Monoid w, MonadPeelIO m) => MonadPeelIO (WriterT w m) Source # | |

MonadPeelIO m => MonadPeelIO (StateT s m) Source # | |

MonadPeelIO m => MonadPeelIO (StateT s m) Source # | |

MonadPeelIO m => MonadPeelIO (IdentityT * m) Source # | |

MonadPeelIO m => MonadPeelIO (ExceptT e m) Source # | |

(Error e, MonadPeelIO m) => MonadPeelIO (ErrorT e m) Source # | |

MonadPeelIO m => MonadPeelIO (ReaderT * r m) Source # | |

(Monoid w, MonadPeelIO m) => MonadPeelIO (RWST r w s m) Source # | |

(Monoid w, MonadPeelIO m) => MonadPeelIO (RWST r w s m) Source # | |