snoyberg/failure — pull request #1 by jberryman (2012-01-15 01:15:21+00:00)
Title: instance (Exception e)=> Failure e (Either SomeException)

I'm still exploring the `failure` library and how it can work with other stuff in the haskell exception-handling ecosystem, but I think this may be a good addition.

take this code:

{-# LANGUAGE DeriveDataTypeable , FlexibleContexts , FlexibleInstances , MultiParamTypeClasses #-}
module Main
where

import Control.Failure
import Control.Exception hiding (try)
import Data.Typeable

data Foo = Foo deriving (Show,Typeable)
data Bar = Bar deriving (Show,Typeable)

instance Exception Foo
instance Exception Bar

This change lets us do something like:

*Main> :t failure Foo >> failure Bar >> Right True
failure Foo >> failure Bar >> Right True
:: (Failure Bar (Either a), Failure Foo (Either a)) =>
Either a Bool
*Main>
*Main> failure Foo >> failure Bar >> Right True :: Either SomeException Bool
Left Foo

...which I think is quite useful.