blob: d06a2d29c7d808d9ee3d38ef6099993909319d8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
{-# LANGUAGE DeriveDataTypeable #-}
module Main where
import Control.Exception (throwIO, Exception)
import Control.Monad (when)
import Data.Typeable (Typeable)
data Boom = Boom deriving (Show, Typeable)
instance Exception Boom
main = do
args <- return []
-- Should throw this exception.
when (length args /= 1) (throwIO Boom)
-- With -O, instead throws this one from head [].
let n = read (head args)
print (n :: Int)
return ()
|