Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Exception e (ex :: Effects)
- try :: forall e (es :: Effects) a. (forall (ex :: Effects). Exception e ex -> Eff (ex :& es) a) -> Eff es (Either e a)
- handle :: forall e (es :: Effects) a. (e -> Eff es a) -> (forall (ex :: Effects). Exception e ex -> Eff (ex :& es) a) -> Eff es a
- catch :: forall e (es :: Effects) a. (forall (ex :: Effects). Exception e ex -> Eff (ex :& es) a) -> (e -> Eff es a) -> Eff es a
- throw :: forall (ex :: Effects) (es :: Effects) e a. ex :> es => Exception e ex -> e -> Eff es a
Handle
Handlers
:: forall e (es :: Effects) a. (forall (ex :: Effects). Exception e ex -> Eff (ex :& es) a) | |
-> Eff es (Either e a) |
|
>>> runPureEff $ try $ \e -> do throw e 42 pure "No exception thrown" Left 42
:: forall e (es :: Effects) a. (e -> Eff es a) | If the exception is thrown, apply this handler |
-> (forall (ex :: Effects). Exception e ex -> Eff (ex :& es) a) | |
-> Eff es a |
handle
, but with the argument order swapped
>>> runPureEff $ handle (pure . show) $ \e -> do throw e 42 pure "No exception thrown" "42"