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

import Control.Monad
import Control.Monad.Fail
import Data.Maybe

test :: (MonadPlus m, MonadFail 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)