2 % (c) The University of Glasgow, 2000-2006
4 \section{Fast integers and booleans}
8 -- The above warning supression flag is a temporary kludge.
9 -- While working on this module you are encouraged to remove it and fix
10 -- any warnings in the module. See
11 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
15 FastInt, _ILIT, iBox, iUnbox,
16 (+#), (-#), (*#), quotFastInt, negateFastInt,
17 (==#), (<#), (<=#), (>=#), (>#),
19 FastBool, fastBool, isFastTrue, fastOr, fastAnd
22 #include "HsVersions.h"
24 #if defined(__GLASGOW_HASKELL__)
28 ( Int(..), Int#, (+#), (-#), (*#),
29 quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
36 quotFastInt = quotInt#
37 negateFastInt = negateInt#
42 isFastTrue x = x ==# 1#
44 -- note that fastOr and fastAnd are strict in both arguments
45 -- since they are unboxed
52 #else /* ! __GLASGOW_HASKELL__ */
62 negateFastInt = negate
72 -- make sure these are as strict as the unboxed version,
73 -- so that the performance characteristics match
74 fastOr False False = False
76 fastAnd True True = True
79 --These are among the type-signatures necessary for !ghc to compile
80 -- but break ghc (can't give a signature for an import...)
81 --Note that the comparisons actually do return Bools not FastBools.
82 (+#) :: FastInt -> FastInt -> FastInt
83 (-#) :: FastInt -> FastInt -> FastInt
84 (*#) :: FastInt -> FastInt -> FastInt
85 (==#) :: FastInt -> FastInt -> Bool
86 (<#) :: FastInt -> FastInt -> Bool
87 (<=#) :: FastInt -> FastInt -> Bool
88 (>=#) :: FastInt -> FastInt -> Bool
89 (>#) :: FastInt -> FastInt -> Bool
91 #endif /* ! __GLASGOW_HASKELL__ */
93 -- type-signatures will improve the non-ghc-specific versions
94 -- and keep things accurate (and ABLE to compile!)
95 _ILIT :: Int -> FastInt
96 iBox :: FastInt -> Int
97 iUnbox :: Int -> FastInt
99 quotFastInt :: FastInt -> FastInt -> FastInt
100 negateFastInt :: FastInt -> FastInt
102 fastBool :: Bool -> FastBool
103 isFastTrue :: FastBool -> Bool
104 fastOr :: FastBool -> FastBool -> FastBool
105 fastAnd :: FastBool -> FastBool -> FastBool