Skip to content

Instantly share code, notes, and snippets.

@mostalive
Last active June 15, 2016 12:24
Show Gist options
  • Save mostalive/dd8dac34bf435f31399440a0fa7f75c1 to your computer and use it in GitHub Desktop.
Save mostalive/dd8dac34bf435f31399440a0fa7f75c1 to your computer and use it in GitHub Desktop.
Purescript - remove exception in Aff
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