<div>I have some exception types defined ...</div><div><br></div><div><div>    data POSTOnlyException = POSTOnlyException</div><div>        deriving ( Show, Typeable )</div><div>    instance Exception POSTOnlyException</div>

<div><br></div><div>    data BadPathException = BadPathException</div><div>        deriving ( Show, Typeable )</div><div>    instance Exception BadPathException</div></div><div><br></div><div>... and I want to use Data.Enumerator.catchError ...</div>

<div><br></div><div>    catchError :: Monad m =&gt; Iteratee a m b -&gt; (SomeException -&gt; Iteratee a m b) -&gt; Iteratee a m b</div><div><br></div><div>... so I define an error handler ...</div><div><br></div><div>    handleErrors :: SomeException -&gt; Iteratee a m String</div>

<div>    handleErrors ex = case fromException ex of</div><div>        Just POSTOnlyException -&gt; return &quot;POSTs only!&quot;</div><div>        Just BadPathException -&gt; return &quot;Bad path!&quot;</div><div>        _ -&gt; return &quot;Unknown exception!&quot;</div>

<div><br></div><div>... but of course this doesn&#39;t compile, because the types of the LHSs in the case statement are different. I can get around it with some ugliness ...</div><div><br></div><div><div>    handleErrors :: SomeException -&gt; Iteratee a m String</div>

<div>    handleErrors ex = case fromException ex of</div><div>        Just POSTOnlyException -&gt; return &quot;POSTs only!&quot;</div><div>        _ -&gt; case fromException ex of</div><div>            Just BadPathException -&gt; return &quot;Bad path!&quot;</div>

<div>            _ -&gt; return &quot;Unknown exception!&quot;</div></div><div><br></div><div>... but there must be a better way. Enlighten me?</div><div><br></div><div>Cheers,</div>Mike S Craig