summaryrefslogtreecommitdiff
path: root/tests/examples/failing/dsrun010.hs
blob: 1d4fc485e0d6e1f96d25ce029e6f8524ca05e356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)