%
% (c) The University of Glasgow, 20002006
%
\section{Fast booleans}
\begin{code}
module FastBool (
FastBool, fastBool, isFastTrue, fastOr, fastAnd
) where
#if defined(__GLASGOW_HASKELL__)
import GHC.Exts
#ifdef DEBUG
import Panic
#endif
type FastBool = Int#
fastBool True = 1#
fastBool False = 0#
#ifdef DEBUG
isFastTrue 1# = True
isFastTrue 0# = False
isFastTrue _ = panic "FastTypes: isFastTrue"
fastOr 1# _ = 1#
fastOr 0# x = x
fastOr _ _ = panicFastInt "FastTypes: fastOr"
fastAnd 0# _ = 0#
fastAnd 1# x = x
fastAnd _ _ = panicFastInt "FastTypes: fastAnd"
#else /* ! DEBUG */
isFastTrue 0# = False
isFastTrue _ = True
fastOr 0# x = x
fastOr _ _ = 1#
fastAnd 0# _ = 0#
fastAnd _ x = x
#endif /* ! DEBUG */
#else /* ! __GLASGOW_HASKELL__ */
type FastBool = Bool
fastBool x = x
isFastTrue x = x
fastOr False False = False
fastOr _ _ = True
fastAnd True True = True
fastAnd _ _ = False
#endif /* ! __GLASGOW_HASKELL__ */
fastBool :: Bool -> FastBool
isFastTrue :: FastBool -> Bool
fastOr :: FastBool -> FastBool -> FastBool
fastAnd :: FastBool -> FastBool -> FastBool
\end{code}