22-- | with JavaScript exceptions.
33
44module Control.Monad.Eff.Exception
5- ( EXCEPTION ()
6- , Error ()
5+ ( EXCEPTION
6+ , Error
77 , error
88 , message
99 , stack
@@ -12,9 +12,11 @@ module Control.Monad.Eff.Exception
1212 , throw
1313 ) where
1414
15- import Prelude
15+ import Control.Monad.Eff (Eff )
16+ import Control.Semigroupoid ((<<<))
17+
1618import Data.Maybe (Maybe (..))
17- import Control.Monad.Eff ( Eff () )
19+ import Data.Show ( class Show )
1820
1921-- | This effect is used to annotate code which possibly throws exceptions
2022foreign import data EXCEPTION :: !
@@ -37,7 +39,11 @@ foreign import message :: Error -> String
3739stack :: Error -> Maybe String
3840stack = stackImpl Just Nothing
3941
40- foreign import stackImpl :: (forall a . a -> Maybe a ) -> (forall a . Maybe a ) -> Error -> Maybe String
42+ foreign import stackImpl
43+ :: (forall a . a -> Maybe a )
44+ -> (forall a . Maybe a )
45+ -> Error
46+ -> Maybe String
4147
4248-- | Throw an exception
4349-- |
@@ -49,7 +55,10 @@ foreign import stackImpl :: (forall a. a -> Maybe a) -> (forall a. Maybe a) -> E
4955-- | when (x < 0) $ throwException $
5056-- | error "Expected a non-negative number"
5157-- | ```
52- foreign import throwException :: forall a eff . Error -> Eff (err :: EXCEPTION | eff ) a
58+ foreign import throwException
59+ :: forall a eff
60+ . Error
61+ -> Eff (err :: EXCEPTION | eff ) a
5362
5463-- | Catch an exception by providing an exception handler.
5564-- |
@@ -61,7 +70,11 @@ foreign import throwException :: forall a eff. Error -> Eff (err :: EXCEPTION |
6170-- | main = catchException print do
6271-- | trace "Exceptions thrown in this block will be logged to the console"
6372-- | ```
64- foreign import catchException :: forall a eff . (Error -> Eff eff a ) -> Eff (err :: EXCEPTION | eff ) a -> Eff eff a
73+ foreign import catchException
74+ :: forall a eff
75+ . (Error -> Eff eff a )
76+ -> Eff (err :: EXCEPTION | eff ) a
77+ -> Eff eff a
6578
6679-- | A shortcut allowing you to throw an error in one step. Defined as
6780-- | `throwException <<< error`.
0 commit comments