/usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html is in libghc-mtl-doc 2.2.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Monad.Except</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Monad-Except.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Monad-Except.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">mtl-2.2.1: Monad classes, using functional dependencies</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>(c) Michael Weber <michael.weber@post.rwth-aachen.de> 2001,
(c) Jeff Newbern 2003-2006,
(c) Andriy Palamarchuk 2006</td></tr><tr><th>License</th><td>BSD-style (see the file LICENSE)</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>non-portable (multi-parameter type classes)</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Control.Monad.Except</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Monads with error handling</a></li><li><a href="#g:2">The ErrorT monad transformer</a></li><li><a href="#g:3">Example 1: Custom Error Data Type</a></li><li><a href="#g:4">Example 2: Using ExceptT Monad Transformer</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><dl><dt>Computation type:</dt><dd>Computations which may fail or throw exceptions.</dd><dt>Binding strategy:</dt><dd>Failure records information about the cause/location
of the failure. Failure values bypass the bound function,
other values are used as inputs to the bound function.</dd><dt>Useful for:</dt><dd>Building computations from sequences of functions that may fail
or using exception handling to structure error handling.</dd><dt>Example type:</dt><dd><code><code><a href="Data.html#v:Either">Either</a></code> String a</code></dd></dl><p>The Error monad (also called the Exception monad).</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="#t:MonadError">MonadError</a> e m | m -> e <span class="keyword">where</span><ul class="subs"></ul></li><li class="src short"><span class="keyword">newtype</span> <a href="#t:ExceptT">ExceptT</a> e m a :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> = <a href="#v:ExceptT">ExceptT</a> (m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a))</li><li class="src short"><span class="keyword">type</span> <a href="#t:Except">Except</a> e = <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a></li><li class="src short"><a href="#v:runExceptT">runExceptT</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a)</li><li class="src short"><a href="#v:mapExceptT">mapExceptT</a> :: (m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a) -> n (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e' b)) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e' n b</li><li class="src short"><a href="#v:withExceptT">withExceptT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> m => (e -> e') -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e' m a</li><li class="src short"><a href="#v:runExcept">runExcept</a> :: <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a</li><li class="src short"><a href="#v:mapExcept">mapExcept</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e' b) -> <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="Control-Monad-Except.html#t:Except">Except</a> e' b</li><li class="src short"><a href="#v:withExcept">withExcept</a> :: (e -> e') -> <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="Control-Monad-Except.html#t:Except">Except</a> e' a</li><li class="src short">module <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html">Control.Monad</a></li><li class="src short">module <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fix.html">Control.Monad.Fix</a></li><li class="src short">module <a href="Control-Monad-Trans.html">Control.Monad.Trans</a></li></ul></div><div id="interface"><h1 id="g:1">Monads with error handling</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a id="t:MonadError" class="def">MonadError</a> e m | m -> e <span class="keyword">where</span> <a href="src/Control-Monad-Error-Class.html#MonadError" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></p><div class="doc"><p>The strategy of combining computations that can throw exceptions
by bypassing bound functions
from the point an exception is thrown to the point that it is handled.</p><p>Is parameterized over the type of error information and
the monad type constructor.
It is common to use <code><code><a href="Data.html#v:Either">Either</a></code> String</code> as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the <code><a href="Control-Monad-Except.html#t:MonadError">MonadError</a></code> class.
You can also define your own error type and/or use a monad type constructor
other than <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a></code> <code>String</code></code> or <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a></code> <code>IOError</code></code>.
In these cases you will have to explicitly define instances of the <code><a href="Control-Monad-Error-Class.html#t:Error">Error</a></code>
and/or <code><a href="Control-Monad-Except.html#t:MonadError">MonadError</a></code> classes.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Control-Monad-Except.html#v:throwError">throwError</a>, <a href="Control-Monad-Except.html#v:catchError">catchError</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:throwError" class="def">throwError</a> :: e -> m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><div class="doc"><p>Is used within a monadic computation to begin exception processing.</p></div><p class="src"><a id="v:catchError" class="def">catchError</a> :: m a -> (e -> m a) -> m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p><div class="doc"><p>A handler function to handle previous errors and return to normal execution.
A common idiom is:</p><pre>do { action1; action2; action3 } `catchError` handler</pre><p>where the <code>action</code> functions can call <code><a href="Control-Monad-Except.html#v:throwError">throwError</a></code>.
Note that <code>handler</code> and the do-block must have the same return type.</p></div></div><div class="subs instances"><p id="control.i:MonadError" class="caption collapser" onclick="toggleSection('i:MonadError')">Instances</p><div id="section.i:MonadError" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:1" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:1')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a></span> <a href="src/Control-Monad-Error-Class.html#line-100" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> a -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:2" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:2')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m)</span> <a href="src/Control-Monad-Error-Class.html#line-134" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a -> (e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:3" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:3')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-List.html#t:ListT">ListT</a> m)</span> <a href="src/Control-Monad-Error-Class.html#line-130" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-List.html#t:ListT">ListT</a> m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-List.html#t:ListT">ListT</a> m a -> (e -> <a href="Control-Monad-List.html#t:ListT">ListT</a> m a) -> <a href="Control-Monad-List.html#t:ListT">ListT</a> m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:4" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:4')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e)</span> <a href="src/Control-Monad-Error-Class.html#line-107" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a -> (e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:5" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:5')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w, <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m) => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m)</span> <a href="src/Control-Monad-Error-Class.html#line-162" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a -> (e -> <a href="Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a) -> <a href="Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:6" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:6')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w, <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m) => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m)</span> <a href="src/Control-Monad-Error-Class.html#line-158" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:6" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a -> (e -> <a href="Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a) -> <a href="Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:7" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:7')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-State-Strict.html#t:StateT">StateT</a> s m)</span> <a href="src/Control-Monad-Error-Class.html#line-154" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:7" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a -> (e -> <a href="Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a) -> <a href="Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:8" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:8')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m)</span> <a href="src/Control-Monad-Error-Class.html#line-150" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a -> (e -> <a href="Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a) -> <a href="Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:9" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:9')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m)</span> <a href="src/Control-Monad-Error-Class.html#line-126" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a -> (e -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:10" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:10')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Error-Class.html#line-116" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> (e -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:11" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:11')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="Control-Monad-Error-Class.html#t:Error">Error</a> e) => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m)</span> <a href="src/Control-Monad-Error-Class.html#line-112" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a -> (e -> <a href="Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a) -> <a href="Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:12" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:12')"></span> <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m)</span> <a href="src/Control-Monad-Error-Class.html#line-138" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:12" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a -> (e -> <a href="Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a) -> <a href="Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:13" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:13')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w, <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m) => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m)</span> <a href="src/Control-Monad-Error-Class.html#line-146" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:13" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a -> (e -> <a href="Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a) -> <a href="Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadError:MonadError:14" class="instance expander" onclick="toggleSection('i:ic:MonadError:MonadError:14')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w, <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e m) => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m)</span> <a href="src/Control-Monad-Error-Class.html#line-142" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadError:MonadError:14" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a -> (e -> <a href="Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a) -> <a href="Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h1 id="g:2">The ErrorT monad transformer</h1><div class="top"><p class="src"><span class="keyword">newtype</span> <a id="t:ExceptT" class="def">ExceptT</a> e m a :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:ExceptT" class="selflink">#</a></p><div class="doc"><p>A monad transformer that adds exceptions to other monads.</p><p><code>ExceptT</code> constructs a monad parameterized over two things:</p><ul><li>e - The exception type.</li><li>m - The inner monad.</li></ul><p>The <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:return">return</a></code> function yields a computation that produces the given
value, while <code>>>=</code> sequences two subcomputations, exiting on the
first exception.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:ExceptT" class="def">ExceptT</a> (m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a))</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:ExceptT" class="caption collapser" onclick="toggleSection('i:ExceptT')">Instances</p><div id="section.i:ExceptT" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadRWS:1" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadRWS:1')"></span> <a href="Control-Monad-RWS-Class.html#t:MonadRWS">MonadRWS</a> r w s m => <a href="Control-Monad-RWS-Class.html#t:MonadRWS">MonadRWS</a> r w s (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-RWS-Class.html#line-57" class="link">Source</a> <a href="#t:MonadRWS" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadRWS:1" class="inst-details hide"></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadWriter:2" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadWriter:2')"></span> <a href="Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w m => <a href="Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Writer-Class.html#line-139" class="link">Source</a> <a href="#t:MonadWriter" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadWriter:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:writer">writer</a> :: (a, w) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Writer-Class.html#writer" class="link">Source</a> <a href="#v:writer" class="selflink">#</a></p><p class="src"><a href="#v:tell">tell</a> :: w -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m () <a href="src/Control-Monad-Writer-Class.html#tell" class="link">Source</a> <a href="#v:tell" class="selflink">#</a></p><p class="src"><a href="#v:listen">listen</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m (a, w) <a href="src/Control-Monad-Writer-Class.html#listen" class="link">Source</a> <a href="#v:listen" class="selflink">#</a></p><p class="src"><a href="#v:pass">pass</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m (a, w -> w) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Writer-Class.html#pass" class="link">Source</a> <a href="#v:pass" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadState:3" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadState:3')"></span> <a href="Control-Monad-State-Class.html#t:MonadState">MonadState</a> s m => <a href="Control-Monad-State-Class.html#t:MonadState">MonadState</a> s (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-State-Class.html#line-135" class="link">Source</a> <a href="#t:MonadState" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadState:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:get">get</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m s <a href="src/Control-Monad-State-Class.html#get" class="link">Source</a> <a href="#v:get" class="selflink">#</a></p><p class="src"><a href="#v:put">put</a> :: s -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m () <a href="src/Control-Monad-State-Class.html#put" class="link">Source</a> <a href="#v:put" class="selflink">#</a></p><p class="src"><a href="#v:state">state</a> :: (s -> (a, s)) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-State-Class.html#state" class="link">Source</a> <a href="#v:state" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadReader:4" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadReader:4')"></span> <a href="Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r m => <a href="Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Reader-Class.html#line-137" class="link">Source</a> <a href="#t:MonadReader" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadReader:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m r <a href="src/Control-Monad-Reader-Class.html#ask" class="link">Source</a> <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (r -> r) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Reader-Class.html#local" class="link">Source</a> <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (r -> a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Reader-Class.html#reader" class="link">Source</a> <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadError:5" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadError:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Except.html#t:MonadError">MonadError</a> e (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Error-Class.html#line-116" class="link">Source</a> <a href="#t:MonadError" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadError:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwError">throwError</a> :: e -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Error-Class.html#throwError" class="link">Source</a> <a href="#v:throwError" class="selflink">#</a></p><p class="src"><a href="#v:catchError">catchError</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> (e -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Error-Class.html#catchError" class="link">Source</a> <a href="#v:catchError" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadTrans:6" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadTrans:6')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadTrans:6" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Monad:7" class="instance expander" onclick="toggleSection('i:id:ExceptT:Monad:7')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Monad:7" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(>>=)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> (a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(>>)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Functor:8" class="instance expander" onclick="toggleSection('i:id:ExceptT:Functor:8')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Functor:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -> b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(<$)</a> :: a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadFix:9" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadFix:9')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadFix:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mfix">mfix</a> :: (a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:mfix" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadFail:10" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadFail:10')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fail.html#t:MonadFail">MonadFail</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fail.html#t:MonadFail">MonadFail</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadFail:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fail">fail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Applicative:11" class="instance expander" onclick="toggleSection('i:id:ExceptT:Applicative:11')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Applicative:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(<*>)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m (a -> b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*>)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(<*)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Foldable:12" class="instance expander" onclick="toggleSection('i:id:ExceptT:Foldable:12')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Foldable.html#t:Foldable">Foldable</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Foldable.html#t:Foldable">Foldable</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Foldable:12" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fold">fold</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f m -> m <a href="#v:fold" class="selflink">#</a></p><p class="src"><a href="#v:foldMap">foldMap</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => (a -> m) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> m <a href="#v:foldMap" class="selflink">#</a></p><p class="src"><a href="#v:foldr">foldr</a> :: (a -> b -> b) -> b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> b <a href="#v:foldr" class="selflink">#</a></p><p class="src"><a href="#v:foldr-39-">foldr'</a> :: (a -> b -> b) -> b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> b <a href="#v:foldr-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldl">foldl</a> :: (b -> a -> b) -> b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> b <a href="#v:foldl" class="selflink">#</a></p><p class="src"><a href="#v:foldl-39-">foldl'</a> :: (b -> a -> b) -> b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> b <a href="#v:foldl-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldr1">foldr1</a> :: (a -> a -> a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:foldr1" class="selflink">#</a></p><p class="src"><a href="#v:foldl1">foldl1</a> :: (a -> a -> a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:foldl1" class="selflink">#</a></p><p class="src"><a href="#v:toList">toList</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> [a] <a href="#v:toList" class="selflink">#</a></p><p class="src"><a href="#v:null">null</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:null" class="selflink">#</a></p><p class="src"><a href="#v:length">length</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> <a href="#v:length" class="selflink">#</a></p><p class="src"><a href="#v:elem">elem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:elem" class="selflink">#</a></p><p class="src"><a href="#v:maximum">maximum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> a => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:maximum" class="selflink">#</a></p><p class="src"><a href="#v:minimum">minimum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> a => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:minimum" class="selflink">#</a></p><p class="src"><a href="#v:sum">sum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Num">Num</a> a => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:sum" class="selflink">#</a></p><p class="src"><a href="#v:product">product</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Num">Num</a> a => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> a <a href="#v:product" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Traversable:13" class="instance expander" onclick="toggleSection('i:id:ExceptT:Traversable:13')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Traversable.html#t:Traversable">Traversable</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Traversable.html#t:Traversable">Traversable</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Traversable:13" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:traverse">traverse</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f => (a -> f b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> f (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f b) <a href="#v:traverse" class="selflink">#</a></p><p class="src"><a href="#v:sequenceA">sequenceA</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f (f a) -> f (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a) <a href="#v:sequenceA" class="selflink">#</a></p><p class="src"><a href="#v:mapM">mapM</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => (a -> m b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a -> m (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f b) <a href="#v:mapM" class="selflink">#</a></p><p class="src"><a href="#v:sequence">sequence</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f (m a) -> m (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e f a) <a href="#v:sequence" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Eq1:14" class="instance expander" onclick="toggleSection('i:id:ExceptT:Eq1:14')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Eq1">Eq1</a> m) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Eq1">Eq1</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Eq1:14" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftEq">liftEq</a> :: (a -> b -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:liftEq" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Ord1:15" class="instance expander" onclick="toggleSection('i:id:ExceptT:Ord1:15')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Ord1">Ord1</a> m) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Ord1">Ord1</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Ord1:15" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftCompare">liftCompare</a> :: (a -> b -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ordering">Ordering</a>) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ordering">Ordering</a> <a href="#v:liftCompare" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Read1:16" class="instance expander" onclick="toggleSection('i:id:ExceptT:Read1:16')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Read1">Read1</a> m) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Read1">Read1</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Read1:16" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftReadsPrec">liftReadsPrec</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) <a href="#v:liftReadsPrec" class="selflink">#</a></p><p class="src"><a href="#v:liftReadList">liftReadList</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a] <a href="#v:liftReadList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Show1:17" class="instance expander" onclick="toggleSection('i:id:ExceptT:Show1:17')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Show1">Show1</a> m) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Show1">Show1</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Show1:17" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftShowsPrec">liftShowsPrec</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a>) -> ([a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a>) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:liftShowsPrec" class="selflink">#</a></p><p class="src"><a href="#v:liftShowList">liftShowList</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a>) -> ([a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a>) -> [<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:liftShowList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadZip:18" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadZip:18')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Zip.html#t:MonadZip">MonadZip</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Zip.html#t:MonadZip">MonadZip</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadZip:18" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mzip">mzip</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m (a, b) <a href="#v:mzip" class="selflink">#</a></p><p class="src"><a href="#v:mzipWith">mzipWith</a> :: (a -> b -> c) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m c <a href="#v:mzipWith" class="selflink">#</a></p><p class="src"><a href="#v:munzip">munzip</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m (a, b) -> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a, <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b) <a href="#v:munzip" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadIO:19" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadIO:19')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadIO:19" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftIO">liftIO</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:liftIO" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Alternative:20" class="instance expander" onclick="toggleSection('i:id:ExceptT:Alternative:20')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> e) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Alternative">Alternative</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Alternative:20" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(<|>)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m [a] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m [a] <a href="#v:many" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadPlus:21" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadPlus:21')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> e) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadPlus:21" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mzero">mzero</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:mzero" class="selflink">#</a></p><p class="src"><a href="#v:mplus">mplus</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:mplus" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:MonadCont:22" class="instance expander" onclick="toggleSection('i:id:ExceptT:MonadCont:22')"></span> <a href="Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> m => <a href="Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Cont-Class.html#line-103" class="link">Source</a> <a href="#t:MonadCont" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:MonadCont:22" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:callCC">callCC</a> :: ((a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m b) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Cont-Class.html#callCC" class="link">Source</a> <a href="#v:callCC" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Eq:23" class="instance expander" onclick="toggleSection('i:id:ExceptT:Eq:23')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Eq1">Eq1</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> a) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Eq:23" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Ord:24" class="instance expander" onclick="toggleSection('i:id:ExceptT:Ord:24')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Ord1">Ord1</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> a) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Ord:24" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(<)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(<=)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(>)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(>=)</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62--61-" class="selflink">#</a></p><p class="src"><a href="#v:max">max</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:max" class="selflink">#</a></p><p class="src"><a href="#v:min">min</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="#v:min" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Read:25" class="instance expander" onclick="toggleSection('i:id:ExceptT:Read:25')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Read1">Read1</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> a) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Read:25" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ExceptT:Show:26" class="instance expander" onclick="toggleSection('i:id:ExceptT:Show:26')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> e, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Classes.html#t:Show1">Show1</a> m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> a) => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> (<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a)</span></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:ExceptT:Show:26" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Except" class="def">Except</a> e = <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a> <a href="#t:Except" class="selflink">#</a></p><div class="doc"><p>The parameterizable exception monad.</p><p>Computations are either exceptions or normal values.</p><p>The <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:return">return</a></code> function returns a normal value, while <code>>>=</code> exits on
the first exception. For a variant that continues after an error
and collects all the errors, see <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Applicative-Lift.html#v:Errors">Errors</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:runExceptT" class="def">runExceptT</a> :: <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a) <a href="#v:runExceptT" class="selflink">#</a></p><div class="doc"><p>The inverse of <code><a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:mapExceptT" class="def">mapExceptT</a> :: (m (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a) -> n (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e' b)) -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e' n b <a href="#v:mapExceptT" class="selflink">#</a></p><div class="doc"><p>Map the unwrapped computation using the given function.</p><ul><li><pre><code><a href="Control-Monad-Except.html#v:runExceptT">runExceptT</a></code> (<code><a href="Control-Monad-Except.html#v:mapExceptT">mapExceptT</a></code> f m) = f (<code><a href="Control-Monad-Except.html#v:runExceptT">runExceptT</a></code> m)</pre></li></ul></div></div><div class="top"><p class="src"><a id="v:withExceptT" class="def">withExceptT</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> m => (e -> e') -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a -> <a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a> e' m a <a href="#v:withExceptT" class="selflink">#</a></p><div class="doc"><p>Transform any exceptions thrown by the computation using the
given function.</p></div></div><div class="top"><p class="src"><a id="v:runExcept" class="def">runExcept</a> :: <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a <a href="#v:runExcept" class="selflink">#</a></p><div class="doc"><p>Extractor for computations in the exception monad.
(The inverse of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Except.html#v:except">except</a></code>).</p></div></div><div class="top"><p class="src"><a id="v:mapExcept" class="def">mapExcept</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Either.html#t:Either">Either</a> e' b) -> <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="Control-Monad-Except.html#t:Except">Except</a> e' b <a href="#v:mapExcept" class="selflink">#</a></p><div class="doc"><p>Map the unwrapped computation using the given function.</p><ul><li><pre><code><a href="Control-Monad-Except.html#v:runExcept">runExcept</a></code> (<code><a href="Control-Monad-Except.html#v:mapExcept">mapExcept</a></code> f m) = f (<code><a href="Control-Monad-Except.html#v:runExcept">runExcept</a></code> m)</pre></li></ul></div></div><div class="top"><p class="src"><a id="v:withExcept" class="def">withExcept</a> :: (e -> e') -> <a href="Control-Monad-Except.html#t:Except">Except</a> e a -> <a href="Control-Monad-Except.html#t:Except">Except</a> e' a <a href="#v:withExcept" class="selflink">#</a></p><div class="doc"><p>Transform any exceptions thrown by the computation using the given
function (a specialization of <code><a href="Control-Monad-Except.html#v:withExceptT">withExceptT</a></code>).</p></div></div><div class="top"><p class="src">module <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html">Control.Monad</a></p></div><div class="top"><p class="src">module <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fix.html">Control.Monad.Fix</a></p></div><div class="top"><p class="src">module <a href="Control-Monad-Trans.html">Control.Monad.Trans</a></p></div><h1 id="g:3">Example 1: Custom Error Data Type</h1><div class="doc"><p>Here is an example that demonstrates the use of a custom error data type with
the <code><a href="Control-Monad-Except.html#v:throwError">throwError</a></code> and <code><a href="Control-Monad-Except.html#v:catchError">catchError</a></code> exception mechanism from <code><a href="Control-Monad-Except.html#t:MonadError">MonadError</a></code>.
The example throws an exception if the user enters an empty string
or a string longer than 5 characters. Otherwise it prints length of the string.</p><pre>-- This is the type to represent length calculation error.
data LengthError = EmptyString -- Entered string was empty.
| StringTooLong Int -- A string is longer than 5 characters.
-- Records a length of the string.
| OtherError String -- Other error, stores the problem description.
-- Converts LengthError to a readable message.
instance Show LengthError where
show EmptyString = "The string was empty!"
show (StringTooLong len) =
"The length of the string (" ++ (show len) ++ ") is bigger than 5!"
show (OtherError msg) = msg
-- For our monad type constructor, we use Either LengthError
-- which represents failure using Left LengthError
-- or a successful result of type a using Right a.
type LengthMonad = Either LengthError
main = do
putStrLn "Please enter a string:"
s <- getLine
reportResult (calculateLength s)
-- Wraps length calculation to catch the errors.
-- Returns either length of the string or an error.
calculateLength :: String -> LengthMonad Int
calculateLength s = (calculateLengthOrFail s) `catchError` Left
-- Attempts to calculate length and throws an error if the provided string is
-- empty or longer than 5 characters.
-- The processing is done in Either monad.
calculateLengthOrFail :: String -> LengthMonad Int
calculateLengthOrFail [] = throwError EmptyString
calculateLengthOrFail s | len > 5 = throwError (StringTooLong len)
| otherwise = return len
where len = length s
-- Prints result of the string length calculation.
reportResult :: LengthMonad Int -> IO ()
reportResult (Right len) = putStrLn ("The length of the string is " ++ (show len))
reportResult (Left e) = putStrLn ("Length calculation failed with error: " ++ (show e))</pre></div><h1 id="g:4">Example 2: Using ExceptT Monad Transformer</h1><div class="doc"><p><code><code><a href="Control-Monad-Except.html#t:ExceptT">ExceptT</a></code></code> monad transformer can be used to add error handling to another monad.
Here is an example how to combine it with an <code>IO</code> monad:</p><pre>import Control.Monad.Except
-- An IO monad which can return String failure.
-- It is convenient to define the monad type of the combined monad,
-- especially if we combine more monad transformers.
type LengthMonad = ExceptT String IO
main = do
-- runExceptT removes the ExceptT wrapper
r <- runExceptT calculateLength
reportResult r
-- Asks user for a non-empty string and returns its length.
-- Throws an error if user enters an empty string.
calculateLength :: LengthMonad Int
calculateLength = do
-- all the IO operations have to be lifted to the IO monad in the monad stack
liftIO $ putStrLn "Please enter a non-empty string: "
s <- liftIO getLine
if null s
then throwError "The string was empty!"
else return $ length s
-- Prints result of the string length calculation.
reportResult :: Either String Int -> IO ()
reportResult (Right len) = putStrLn ("The length of the string is " ++ (show len))
reportResult (Left e) = putStrLn ("Length calculation failed with error: " ++ (show e))</pre></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|