On Sat, Dec 19, 2009 at 4:46 PM, ntupel
<ntupel@googlemail.com> wrote:
I have looked at the recently released Control.Failure library but I
admit, I couldn't understand it completely. So given the example
below, how would Control.Failure help me here?
Thanks,
nt
-- Theirs (other library code stubs)
data TheirError = TheirErrorCase deriving Show
data TheirData = TheirData deriving Show
theirFunc :: [String] -> Either TheirError TheirData
theirFunc = undefined
-- Mine (my own code stubs)
data MyError = MyErrorCase deriving Show
data MyData = MyData deriving Show
myFuncA :: TheirData -> Either MyError MyData
myFuncA = undefined
-- Ugly. How to apply Control.Failure here?
myFuncB :: IO (Either MyError MyData)
myFuncB = do
let x = theirFunc []
case x of
Right x' -> return $ myFuncA x'
Left _ -> return . Left $ MyErrorCase
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe