2 % (c) The University of Glasgow, 2000-2006
4 \section{Fast integers and booleans}
8 FastInt, _ILIT, iBox, iUnbox,
9 (+#), (-#), (*#), quotFastInt, negateFastInt,
10 (==#), (<#), (<=#), (>=#), (>#),
12 FastBool, fastBool, isFastTrue, fastOr, fastAnd
15 #include "HsVersions.h"
17 #if defined(__GLASGOW_HASKELL__)
21 ( Int(..), Int#, (+#), (-#), (*#),
22 quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
29 quotFastInt = quotInt#
30 negateFastInt = negateInt#
35 isFastTrue x = x ==# 1#
37 -- note that fastOr and fastAnd are strict in both arguments
38 -- since they are unboxed
45 #else /* ! __GLASGOW_HASKELL__ */
55 negateFastInt = negate
65 -- make sure these are as strict as the unboxed version,
66 -- so that the performance characteristics match
67 fastOr False False = False
69 fastAnd True True = True
72 --These are among the type-signatures necessary for !ghc to compile
73 -- but break ghc (can't give a signature for an import...)
74 (+#) :: FastInt -> FastInt -> FastInt
75 (-#) :: FastInt -> FastInt -> FastInt
76 (*#) :: FastInt -> FastInt -> FastInt
77 (==#) :: FastInt -> FastInt -> Bool
78 (<#) :: FastInt -> FastInt -> Bool
79 (<=#) :: FastInt -> FastInt -> Bool
80 (>=#) :: FastInt -> FastInt -> Bool
81 (>#) :: FastInt -> FastInt -> Bool
83 #endif /* ! __GLASGOW_HASKELL__ */
84 -- however it's still possible to check that these are
85 -- valid signatures nonetheless (e.g., ==# returns Bool
86 -- not FastBool/Int# !)
88 ( (+#) :: FastInt -> FastInt -> FastInt
89 , (-#) :: FastInt -> FastInt -> FastInt
90 , (*#) :: FastInt -> FastInt -> FastInt
91 , (==#) :: FastInt -> FastInt -> Bool
92 , (<#) :: FastInt -> FastInt -> Bool
93 , (<=#) :: FastInt -> FastInt -> Bool
94 , (>=#) :: FastInt -> FastInt -> Bool
95 , (>#) :: FastInt -> FastInt -> Bool
98 -- type-signatures will improve the non-ghc-specific versions
99 -- and keep things accurate (and ABLE to compile!)
100 _ILIT :: Int -> FastInt
101 iBox :: FastInt -> Int
102 iUnbox :: Int -> FastInt
104 quotFastInt :: FastInt -> FastInt -> FastInt
105 negateFastInt :: FastInt -> FastInt
107 fastBool :: Bool -> FastBool
108 isFastTrue :: FastBool -> Bool
109 fastOr :: FastBool -> FastBool -> FastBool
110 fastAnd :: FastBool -> FastBool -> FastBool