summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal/should_run/T13380e.hs
blob: b69dfd51e9a0e1cbe5b5e1a3a633f4bad2bc9846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Control.Exception

-- This is just like T13380d, but doesn't look through the IO abstraction.
-- With Nested CPR, it will result in very similar code, however!

-- | An IO action that throws a precise exception that isn't inlined.
throws :: IO ()
throws = throwIO (userError "What")
{-# NOINLINE throws #-}

{-# NOINLINE f #-}
f :: Int -> Int -> IO Int
-- à la #13380
f x y | x>0       = throws >> return 0
      | y>0       = return 1
      | otherwise = return 2

main = f 2 undefined >>= print