You might want to make a local version of ErrorT in your library, to avoid the silly 'Error' class restriction. This is pretty easy; just copy it from the 'transformers' or 'mtl' package.
On Sat, May 1, 2010 at 14:42, Ryan Ingram <ryani.s...@gmail.com> wrote: > Check out ErrorT in Control.Monad.Error > >> :t ErrorT > ErrorT :: m (Either e a) -> ErrorT e m a > >> :info ErrorT > instance (Monad m, Error e) => Monad (ErrorT e m) > >> :info Error > class Error e where > noMsg :: e > strMsg :: String -> e > > So, if you can make your Error type an instance of this class, you can do > this: > > runCalc = runErrorT (ErrorT (func1 p) >>= ErrorT . func2) > > The restriction to the typeclass Error is to allow implementation of > the "fail" method in Monad. > > -- ryan > > > 2010/5/1 Eugeny N Dzhurinsky <b...@redwerk.com>: >> Hello! >> >> I have some sort of strange question: >> >> assume that there are 2 functions >> >> func1 :: Int -> IO (Either Error String) >> func2 :: String -> IO (Either Error [String]) >> >> in case if there will be no IO involved, I could use >> Control.Monad.Either and write something like >> >> runCalc :: Int -> IO (Either Error [String]) >> runCalc param = func1 param >>= func2 >> >> but with that IO stuff I can't simply do in this way. Can somebody please >> suggest, how to combine IO and Either monads, if that's even possible? >> >> Thank you in advance! >> >> -- >> Eugene Dzhurinsky >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe