[project @ 2000-10-12 13:11:45 by simonmar]
[ghc-hetmet.git] / ghc / compiler / utils / FastTypes.lhs
1 %
2 % (c) The University of Glasgow, 2000
3 %
4 \section{Fast integers and booleans}
5
6 \begin{code}
7 module FastTypes (
8     FastInt, _ILIT, iBox, iUnbox,
9     (+#), (-#), (*#), quotFastInt, negateFastInt,
10     (==#), (<#), (<=#), (>=#), (>#),
11
12     FastBool, fastBool, _IS_TRUE_
13   ) where
14
15 #if defined(__GLASGOW_HASKELL__)
16
17 -- Import the beggars
18 import GlaExts
19         ( Int(..), Int#, (+#), (-#), (*#), 
20           quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
21         )
22
23 type FastInt = Int#
24 _ILIT (I# x) = x
25 iBox x = I# x
26 iUnbox (I# x) = x
27 quotFastInt   = quotInt#
28 negateFastInt = negateInt#
29
30 type FastBool = Int#
31 fastBool True  = 1#
32 fastBool False = 0#
33 _IS_TRUE_ x = x ==# 1#
34
35 #else {- ! __GLASGOW_HASKELL__ -}
36
37 type FastInt = Int
38 _ILIT x = x
39 iBox x = x
40 iUnbox x = x
41 (+#) = (+)
42 (-#) = (-)
43 (*#) = (*)
44 quotFastInt   = quot
45 negateFastInt = negate
46 (==#) = (==)
47 (<#)  = (<)
48 (<=#) = (<=)
49 (>=#) = (>=)
50 (>#)  = (>)
51
52 type FastBool = Bool
53 fastBool x = x
54 _IS_TRUE_ x = x
55
56 #endif  {- ! __GLASGOW_HASKELL__ -}
57 \end{code}