Last active
June 15, 2016 12:24
-
-
Save mostalive/dd8dac34bf435f31399440a0fa7f75c1 to your computer and use it in GitHub Desktop.
Purescript - remove exception in Aff
This file contains 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 characters
module Main where | |
import Prelude (($), bind,id, pure) | |
import Control.Monad.Eff.Exception (Error, EXCEPTION, catchException, message) | |
import Control.Monad.Aff (Aff, attempt) | |
import Control.Monad.Aff.Unsafe (unsafeInterleaveAff) | |
import Data.Either (either) | |
catchException' :: forall e a. (Error -> a) -> Aff (err :: EXCEPTION | e ) a -> Aff e a | |
catchException' handler f = do | |
e <- attempt (unsafeInterleaveAff f) | |
pure $ either handler id e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment