Created
July 20, 2015 09:22
Revisions
-
hvr created this gist
Jul 20, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad.Identity import Control.Monad.Except import Control.Monad.State.Strict type SET s e m = StateT s (ExceptT e m) type EST e s m = ExceptT e (StateT s m) type SE s e = StateT s (Except e) type ES e s = ExceptT e (State s) data St = St data Err = Err -- errors w/ rollback runES :: forall e s a . ES e s a -> s -> (Either e a, s) runES act s0 = runState (runExceptT act :: State s (Either e a)) s0 -- errors w/o rollback runSE :: forall s e a . SE s e a -> s -> Either e (a,s) runSE act s0 = runExcept (runStateT act s0)