bce98f479c0ffb5cb19a75cbe2cc8994591a658d
[ghc-hetmet.git] / compiler / utils / FastTypes.lhs
1 %
2 % (c) The University of Glasgow, 2000-2006
3 %
4 \section{Fast integers and booleans}
5
6 \begin{code}
7 module FastTypes (
8     FastInt, _ILIT, iBox, iUnbox,
9     (+#), (-#), (*#), quotFastInt, negateFastInt,
10     (==#), (<#), (<=#), (>=#), (>#),
11   ) where
12
13 #if defined(__GLASGOW_HASKELL__)
14
15 -- Import the beggars
16 import GHC.Exts
17         ( Int(..), Int#, (+#), (-#), (*#), 
18           quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
19         )
20
21 type FastInt = Int#
22 _ILIT (I# x) = x
23 iBox x = I# x
24 iUnbox (I# x) = x
25 quotFastInt   = quotInt#
26 negateFastInt = negateInt#
27
28 #else /* ! __GLASGOW_HASKELL__ */
29
30 type FastInt = Int
31 _ILIT x = x
32 iBox x = x
33 iUnbox x = x
34 (+#) = (+)
35 (-#) = (-)
36 (*#) = (*)
37 quotFastInt   = quot
38 negateFastInt = negate
39 (==#) = (==)
40 (<#)  = (<)
41 (<=#) = (<=)
42 (>=#) = (>=)
43 (>#)  = (>)
44
45 --These are among the type-signatures necessary for !ghc to compile
46 -- but break ghc (can't give a signature for an import...)
47 --Note that the comparisons actually do return Bools not FastBools.
48 (+#) :: FastInt -> FastInt -> FastInt
49 (-#) :: FastInt -> FastInt -> FastInt
50 (*#) :: FastInt -> FastInt -> FastInt
51 (==#) :: FastInt -> FastInt -> Bool
52 (<#) :: FastInt -> FastInt -> Bool
53 (<=#) :: FastInt -> FastInt -> Bool
54 (>=#) :: FastInt -> FastInt -> Bool
55 (>#) :: FastInt -> FastInt -> Bool
56
57 #endif /* ! __GLASGOW_HASKELL__ */
58
59 -- type-signatures will improve the non-ghc-specific versions
60 -- and keep things accurate (and ABLE to compile!)
61 _ILIT :: Int -> FastInt
62 iBox :: FastInt -> Int
63 iUnbox :: Int -> FastInt
64
65 quotFastInt :: FastInt -> FastInt -> FastInt
66 negateFastInt :: FastInt -> FastInt
67
68 \end{code}