1-- | Support for checked exceptions.
10import Control.Exception
14import Effectful.Internal.Effect
15import Effectful.Internal.Env
16import Effectful.Internal.Monad
17import Effectful.Internal.Utils
19type role Error nominal phantom phantom
20data Error e :: Effect where
24 :: forall e es a. Exception e
25 => Eff (Error e : es) a
26 -> Eff es (Either ([String], e) a)
27runError (Eff m) = unsafeEff $ \es0 -> mask $ \release -> do
29 es <- unsafeConsEnv (IdE (Error @e)) noRelinker es0
30 try (release $ m es) >>= \case
31 Right a -> Right a <$ unsafeTailEnv size0 es
32 Left (WrapErr cs e) -> Left (cs, e) <$ unsafeTailEnv size0 es
35 :: (HasCallStack, Exception e, Error e :> es)
38throwError e = unsafeEff_ $ do
39 throwIO $ WrapErr (ppCallStack <$> getCallStack callStack) e
42 :: (Exception e, Error e :> es)
44 -> ([String] -> e -> Eff es a)
46catchError (Eff m) handler = unsafeEff $ \es -> do
48 m es `catch` \(WrapErr e cs) -> do
50 unEff (handler e cs) es
53 :: (Exception e, Error e :> es)
55 -> Eff es (Either ([String], e) a)
56tryError m = (Right <$> m) `catchError` \es e -> pure (Left (es, e))
58----------------------------------------
61data WrapErr e = WrapErr [String] e
63instance (Show e, Typeable e) => Exception (WrapErr 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