summaryrefslogtreecommitdiff
path: root/tests/examples/failing/dsrun010.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/examples/failing/dsrun010.hs')
-rwxr-xr-xtests/examples/failing/dsrun010.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/examples/failing/dsrun010.hs b/tests/examples/failing/dsrun010.hs
new file mode 100755
index 0000000..1d4fc48
--- /dev/null
+++ b/tests/examples/failing/dsrun010.hs
@@ -0,0 +1,25 @@
+-- Check that pattern match failure in do-notation
+-- is reflected by calling the monadic 'fail', not by a
+-- runtime exception
+
+{-# LANGUAGE NoMonadFailDesugaring #-}
+{-# OPTIONS -Wno-missing-monadfail-instances #-}
+
+import Control.Monad
+import Data.Maybe
+
+test :: (MonadPlus m) => [a] -> m Bool
+test xs
+ = do
+ (_:_) <- return xs
+ -- Should fail here
+ return True
+ `mplus`
+ -- Failure in LH arg should trigger RH arg
+ do
+ return False
+
+main :: IO ()
+main
+ = do let x = fromJust (test [])
+ putStrLn (show x)