> From: Max Cantor <mxcan...@gmail.com> > Sent: Tue, November 2, 2010 7:58:49 AM > > FYI, > > I implemented an error monad using this church-encoded either instead of > the >conventional either. my thought was that since you skip the conditional at >each bind call you'd get better performance. I was quite mistaken.
That's surprising, I think LogicT gains significant performance from that sort of CPS conversion. Was your code like this? newtype ErrorC e a = ErrorC (runErrorC :: forall r . (e -> r) -> (a -> r) -> r) instance Monad (ErrorC e) where return x = ErrorC (\fail succeed -> succeed x) ErrorC part1 >>= f = ErrorC (\fail succeed -> part1 fail (\a -> runErrorC (f a) fail succeed)) instance MonadError e (ErrorC e) where throwError e = ErrorC (\fail succeed -> fail e) catchError m handler = ErrorC (\fail succeed -> runErrorC m (\err -> runErrorC (handler err) fail succeed) succeed) Brandon Moore _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe