[project @ 2001-03-01 15:59:51 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, isFastTrue, fastOr
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 isFastTrue x = x ==# 1#
34
35 fastOr 1# _ = 1#
36 fastOr 0# x = x
37
38 fastAnd 0# x = 0#
39 fastAnd 1# x = x
40
41 #else {- ! __GLASGOW_HASKELL__ -}
42
43 type FastInt = Int
44 _ILIT x = x
45 iBox x = x
46 iUnbox x = x
47 (+#) = (+)
48 (-#) = (-)
49 (*#) = (*)
50 quotFastInt   = quot
51 negateFastInt = negate
52 (==#) = (==)
53 (<#)  = (<)
54 (<=#) = (<=)
55 (>=#) = (>=)
56 (>#)  = (>)
57
58 type FastBool = Bool
59 fastBool x = x
60 _IS_TRUE_ x = x
61
62 #endif  {- ! __GLASGOW_HASKELL__ -}
63 \end{code}