blob: 059057015f738f2d035a5bd3135bb411e125f8e0 (
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
26
27
|
import Data.Bits
import Numeric.Natural
import GHC.Exception.Type
import Control.Exception
main :: IO ()
main = do
test ((42 `shiftR` (-1)) :: Integer)
test ((42 `shiftL` (-1)) :: Integer)
test ((42 `shiftR` (-1)) :: Natural)
test ((42 `shiftL` (-1)) :: Natural)
test ((42 `shiftR` (-1)) :: Word)
test ((42 `shiftL` (-1)) :: Word)
test ((42 `shiftR` (-1)) :: Int)
test ((42 `shiftL` (-1)) :: Int)
test ((42 `unsafeShiftR` 2) :: Integer)
test ((42 `unsafeShiftL` 2) :: Integer)
test ((42 `unsafeShiftR` 2) :: Natural)
test ((42 `unsafeShiftL` 2) :: Natural)
test ((42 `unsafeShiftR` 2) :: Word)
test ((42 `unsafeShiftL` 2) :: Word)
test ((42 `unsafeShiftR` 2) :: Int)
test ((42 `unsafeShiftL` 2) :: Int)
test :: Show a => a -> IO ()
test a = print a `catch` (\Overflow -> putStrLn "Overflow!")
|