1-- | Support for checked exceptions.
10import Control.Exception
14import Effectful.Internal.Env
15import Effectful.Internal.Has
16import Effectful.Internal.Monad
17import Effectful.Internal.Utils
19type role Error nominal
23 :: forall e es a. Exception e
24 => Eff (Error e : es) a
25 -> Eff es (Either ([String], e) a)
26runError (Eff m) = impureEff $ \es0 -> mask $ \release -> do
28 es <- unsafeConsEnv (Error @e) es0
29 try (release $ m es) >>= \case
30 Right a -> Right a <$ unsafeTrimEnv size es
31 Left (WrapE cs e) -> Left (cs, e) <$ unsafeTrimEnv size es
34 :: (HasCallStack, Exception e, Error e :> es)
37throwError e = impureEff_ $ do
38 throwIO $ WrapE (ppCallStack <$> getCallStack callStack) e
41 :: (Exception e, Error e :> es)
43 -> ([String] -> e -> Eff es a)
45catchError (Eff m) handler = impureEff $ \es -> do
47 m es `catch` \(WrapE e cs) -> do
49 unEff (handler e cs) es
52 :: (Exception e, Error e :> es)
54 -> Eff es (Either ([String], e) a)
55tryError m = (Right <$> m) `catchError` \es e -> pure (Left (es, e))
57----------------------------------------
60data WrapE e = WrapE [String] e
62instance (Show e, Typeable e) => Exception (WrapE e)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list