Built-in Natural literals in Core
[ghc.git] / testsuite / tests / numeric / should_compile / T14465.hs
1 {-# LANGUAGE TypeApplications #-}
2 {-# LANGUAGE TypeInType #-}
3
4 module M where
5
6 import Numeric.Natural
7 import GHC.Natural
8
9 -- test Natural literals
10 one :: Natural
11 one = fromInteger 1
12
13 plusOne :: Natural -> Natural
14 plusOne n = n + 1
15
16 -- a built-in rule should convert this unfolding into a Natural literal in Core
17 ten :: Natural
18 ten = wordToNatural 10
19
20 -- test basic constant folding for Natural
21 twoTimesTwo :: Natural
22 twoTimesTwo = 2 * 2
23
24 -- test the overflow warning
25 minusOne :: Natural
26 minusOne = -1