summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_run/dsrun010.hs
blob: 99a9297f8b62299ccc81245b968dd4824981884e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Check that pattern match failure in do-notation
-- is reflected by calling the monadic 'fail', not by a
-- runtime exception

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)