[project @ 2005-01-14 00:00:22 by ross]
authorross <unknown>
Fri, 14 Jan 2005 00:00:22 +0000 (00:00 +0000)
committerross <unknown>
Fri, 14 Jan 2005 00:00:22 +0000 (00:00 +0000)
make these work with Hugs (pending the possible return of Word) and
simplify the #if's a bit.

Data/IntMap.hs
Data/IntSet.hs

index cd3c2f9..ce9f3eb 100644 (file)
@@ -146,63 +146,32 @@ import List (nub,sort)
 import qualified List
 -}  
 
-#ifdef __GLASGOW_HASKELL__
-{--------------------------------------------------------------------
-  GHC: use unboxing to get @shiftRL@ inlined.
---------------------------------------------------------------------}
 #if __GLASGOW_HASKELL__ >= 503
 import GHC.Word
 import GHC.Exts ( Word(..), Int(..), shiftRL# )
-#else
+#elif __GLASGOW_HASKELL__
 import Word
 import GlaExts ( Word(..), Int(..), shiftRL# )
+#else
+import Data.Word
 #endif
 
 infixl 9 \\{-This comment teaches CPP correct behaviour -}
 
-type Nat = Word
-
-natFromInt :: Key -> Nat
-natFromInt i = fromIntegral i
-
-intFromNat :: Nat -> Key
-intFromNat w = fromIntegral w
-
-shiftRL :: Nat -> Key -> Nat
-shiftRL (W# x) (I# i)
-  = W# (shiftRL# x i)
-
-#elif __HUGS__
+#if __HUGS__
 {--------------------------------------------------------------------
- Hugs: 
- * raises errors on boundary values when using 'fromIntegral'
-   but not with the deprecated 'fromInt/toInt'. 
- * Older Hugs doesn't define 'Word'.
- * Newer Hugs defines 'Word' in the Prelude but no operations.
+  Hugs:
+  * Older Hugs doesn't define 'Word'.
+  * Newer Hugs defines 'Word' in the Prelude but no operations.
 --------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\
-
 type Nat = Word32   -- illegal on 64-bit platforms!
-
-natFromInt :: Key -> Nat
-natFromInt i = fromInt i
-
-intFromNat :: Nat -> Key
-intFromNat w = toInt w
-
-shiftRL :: Nat -> Key -> Nat
-shiftRL x i   = shiftR x i
-
 #else
 {--------------------------------------------------------------------
   'Standard' Haskell
   * A "Nat" is a natural machine word (an unsigned Int)
 --------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\
-
 type Nat = Word
+#endif
 
 natFromInt :: Key -> Nat
 natFromInt i = fromIntegral i
@@ -211,11 +180,16 @@ intFromNat :: Nat -> Key
 intFromNat w = fromIntegral w
 
 shiftRL :: Nat -> Key -> Nat
-shiftRL w i   = shiftR w i
-
+#if __GLASGOW_HASKELL__
+{--------------------------------------------------------------------
+  GHC: use unboxing to get @shiftRL@ inlined.
+--------------------------------------------------------------------}
+shiftRL (W# x) (I# i)
+  = W# (shiftRL# x i)
+#else
+shiftRL x i   = shiftR x i
 #endif
 
-
 {--------------------------------------------------------------------
   Operators
 --------------------------------------------------------------------}
index 90b9bd9..5023df6 100644 (file)
@@ -103,64 +103,32 @@ import List (nub,sort)
 import qualified List
 -}
 
-
-#ifdef __GLASGOW_HASKELL__
-{--------------------------------------------------------------------
-  GHC: use unboxing to get @shiftRL@ inlined.
---------------------------------------------------------------------}
 #if __GLASGOW_HASKELL__ >= 503
 import GHC.Word
 import GHC.Exts ( Word(..), Int(..), shiftRL# )
-#else
+#elif __GLASGOW_HASKELL__
 import Word
 import GlaExts ( Word(..), Int(..), shiftRL# )
+#else
+import Data.Word
 #endif
 
 infixl 9 \\{-This comment teaches CPP correct behaviour -}
 
-type Nat = Word
-
-natFromInt :: Int -> Nat
-natFromInt i = fromIntegral i
-
-intFromNat :: Nat -> Int
-intFromNat w = fromIntegral w
-
-shiftRL :: Nat -> Int -> Nat
-shiftRL (W# x) (I# i)
-  = W# (shiftRL# x i)
-
-#elif __HUGS__
+#if __HUGS__
 {--------------------------------------------------------------------
- Hugs: 
- * raises errors on boundary values when using 'fromIntegral'
-   but not with the deprecated 'fromInt/toInt'. 
- * Older Hugs doesn't define 'Word'.
- * Newer Hugs defines 'Word' in the Prelude but no operations.
+  Hugs:
+  * Older Hugs doesn't define 'Word'.
+  * Newer Hugs defines 'Word' in the Prelude but no operations.
 --------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\ -- comment to fool cpp
-
 type Nat = Word32   -- illegal on 64-bit platforms!
-
-natFromInt :: Int -> Nat
-natFromInt i = fromInt i
-
-intFromNat :: Nat -> Int
-intFromNat w = toInt w
-
-shiftRL :: Nat -> Int -> Nat
-shiftRL x i   = shiftR x i
-
 #else
 {--------------------------------------------------------------------
   'Standard' Haskell
   * A "Nat" is a natural machine word (an unsigned Int)
 --------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\ -- comment to fool cpp
-
 type Nat = Word
+#endif
 
 natFromInt :: Int -> Nat
 natFromInt i = fromIntegral i
@@ -169,8 +137,14 @@ intFromNat :: Nat -> Int
 intFromNat w = fromIntegral w
 
 shiftRL :: Nat -> Int -> Nat
-shiftRL w i   = shiftR w i
-
+#if __GLASGOW_HASKELL__
+{--------------------------------------------------------------------
+  GHC: use unboxing to get @shiftRL@ inlined.
+--------------------------------------------------------------------}
+shiftRL (W# x) (I# i)
+  = W# (shiftRL# x i)
+#else
+shiftRL x i   = shiftR x i
 #endif
 
 {--------------------------------------------------------------------