X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FFastTypes.lhs;h=ab5ae460d4709c2a8303cc8c91988d97845b848b;hb=1a7d1b77334529ca96ed4cbc03fcb5f55dc2de4a;hp=bcea61de7805b27d891b74771568923ea714c334;hpb=da72bd5d852ac0e01a00f5d54030a958fbcf72dc;p=ghc-hetmet.git diff --git a/compiler/utils/FastTypes.lhs b/compiler/utils/FastTypes.lhs index bcea61d..ab5ae46 100644 --- a/compiler/utils/FastTypes.lhs +++ b/compiler/utils/FastTypes.lhs @@ -4,6 +4,13 @@ \section{Fast integers and booleans} \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module FastTypes ( FastInt, _ILIT, iBox, iUnbox, (+#), (-#), (*#), quotFastInt, negateFastInt, @@ -34,6 +41,8 @@ fastBool True = 1# fastBool False = 0# isFastTrue x = x ==# 1# +-- note that fastOr and fastAnd are strict in both arguments +-- since they are unboxed fastOr 1# _ = 1# fastOr 0# x = x @@ -60,11 +69,16 @@ negateFastInt = negate type FastBool = Bool fastBool x = x isFastTrue x = x -fastOr = (||) -fastAnd = (&&) +-- make sure these are as strict as the unboxed version, +-- so that the performance characteristics match +fastOr False False = False +fastOr _ _ = True +fastAnd True True = True +fastAnd _ _ = False --These are among the type-signatures necessary for !ghc to compile -- but break ghc (can't give a signature for an import...) +--Note that the comparisons actually do return Bools not FastBools. (+#) :: FastInt -> FastInt -> FastInt (-#) :: FastInt -> FastInt -> FastInt (*#) :: FastInt -> FastInt -> FastInt @@ -75,19 +89,6 @@ fastAnd = (&&) (>#) :: FastInt -> FastInt -> Bool #endif /* ! __GLASGOW_HASKELL__ */ --- however it's still possible to check that these are --- valid signatures nonetheless (e.g., ==# returns Bool --- not FastBool/Int# !) -_signatures = - ( (+#) :: FastInt -> FastInt -> FastInt - , (-#) :: FastInt -> FastInt -> FastInt - , (*#) :: FastInt -> FastInt -> FastInt - , (==#) :: FastInt -> FastInt -> Bool - , (<#) :: FastInt -> FastInt -> Bool - , (<=#) :: FastInt -> FastInt -> Bool - , (>=#) :: FastInt -> FastInt -> Bool - , (>#) :: FastInt -> FastInt -> Bool - ) -- type-signatures will improve the non-ghc-specific versions -- and keep things accurate (and ABLE to compile!)