summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
faa067c)
make these work with Hugs (pending the possible return of Word) and
simplify the #if's a bit.
-#ifdef __GLASGOW_HASKELL__
-{--------------------------------------------------------------------
- GHC: use unboxing to get @shiftRL@ inlined.
---------------------------------------------------------------------}
#if __GLASGOW_HASKELL__ >= 503
import GHC.Word
import GHC.Exts ( Word(..), Int(..), shiftRL# )
#if __GLASGOW_HASKELL__ >= 503
import GHC.Word
import GHC.Exts ( Word(..), Int(..), shiftRL# )
+#elif __GLASGOW_HASKELL__
import Word
import GlaExts ( Word(..), Int(..), shiftRL# )
import Word
import GlaExts ( Word(..), Int(..), shiftRL# )
#endif
infixl 9 \\{-This comment teaches CPP correct behaviour -}
#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__
{--------------------------------------------------------------------
{--------------------------------------------------------------------
- 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!
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)
--------------------------------------------------------------------}
#else
{--------------------------------------------------------------------
'Standard' Haskell
* A "Nat" is a natural machine word (an unsigned Int)
--------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\
-
natFromInt :: Key -> Nat
natFromInt i = fromIntegral i
natFromInt :: Key -> Nat
natFromInt i = fromIntegral i
intFromNat w = fromIntegral w
shiftRL :: Nat -> Key -> Nat
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
{--------------------------------------------------------------------
Operators
--------------------------------------------------------------------}
{--------------------------------------------------------------------
Operators
--------------------------------------------------------------------}
-
-#ifdef __GLASGOW_HASKELL__
-{--------------------------------------------------------------------
- GHC: use unboxing to get @shiftRL@ inlined.
---------------------------------------------------------------------}
#if __GLASGOW_HASKELL__ >= 503
import GHC.Word
import GHC.Exts ( Word(..), Int(..), shiftRL# )
#if __GLASGOW_HASKELL__ >= 503
import GHC.Word
import GHC.Exts ( Word(..), Int(..), shiftRL# )
+#elif __GLASGOW_HASKELL__
import Word
import GlaExts ( Word(..), Int(..), shiftRL# )
import Word
import GlaExts ( Word(..), Int(..), shiftRL# )
#endif
infixl 9 \\{-This comment teaches CPP correct behaviour -}
#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__
{--------------------------------------------------------------------
{--------------------------------------------------------------------
- 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!
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)
--------------------------------------------------------------------}
#else
{--------------------------------------------------------------------
'Standard' Haskell
* A "Nat" is a natural machine word (an unsigned Int)
--------------------------------------------------------------------}
-import Data.Word
-infixl 9 \\ -- comment to fool cpp
-
natFromInt :: Int -> Nat
natFromInt i = fromIntegral i
natFromInt :: Int -> Nat
natFromInt i = fromIntegral i
intFromNat w = fromIntegral w
shiftRL :: Nat -> Int -> Nat
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
{--------------------------------------------------------------------
#endif
{--------------------------------------------------------------------