File tree Expand file tree Collapse file tree 2 files changed +211
-32
lines changed Expand file tree Collapse file tree 2 files changed +211
-32
lines changed Original file line number Diff line number Diff line change 11module Examples where
2+ import Debug.Trace (trace , Trace ())
3+
4+ import Data.Either (either )
5+
26 import Control.Monad.Aff
37 import Control.Monad.Eff.Class (liftEff )
4- import Debug.Trace
5-
8+ import Control.Monad.Eff.Exception (error )
9+ import Control.Monad.Error.Class (throwError )
10+
611 foreign import data Time :: !
712
813 foreign import timeout " " "
@@ -29,6 +34,19 @@ module Examples where
2934 liftEff $ trace (show n ++ " seconds left ")
3035 test_sequencing (n - 1)
3136
37+ test_attempt :: forall e. Aff (trace :: Trace | e ) Unit
38+ test_attempt = do
39+ e <- attempt (throwError (error "Oh noes!"))
40+ liftEff $ either (const $ trace "Exception caught ") (const $ trace "Exception NOT caught !!!") e
41+
3242 main = launchAff $ do
3343 liftEff $ trace " Testing sequencing"
34- test_sequencing 10
44+ test_sequencing 3
45+
46+ liftEff $ trace " Testing attempt"
47+ test_attempt
48+
49+ liftEff $ trace " Testing later"
50+ later $ liftEff $ trace " It happend later"
51+
52+
You can’t perform that action at this time.
0 commit comments