diff options
| author | sof <unknown> | 1998-07-20 10:00:36 +0000 |
|---|---|---|
| committer | sof <unknown> | 1998-07-20 10:00:36 +0000 |
| commit | 71a84ae8038af796185fab59176f6066a1f45098 (patch) | |
| tree | 93eaa552e050f4fc364f497ec6d820de31d2b310 /ghc/lib/exts | |
| parent | a69724d81e0290a898b9992ae5a8a11d01982fa4 (diff) | |
| download | haskell-71a84ae8038af796185fab59176f6066a1f45098.tar.gz | |
[project @ 1998-07-20 10:00:34 by sof]
non-standard extensions: intToWord and wordToInt coercion functions
Diffstat (limited to 'ghc/lib/exts')
| -rw-r--r-- | ghc/lib/exts/Int.lhs | 10 | ||||
| -rw-r--r-- | ghc/lib/exts/Word.lhs | 6 |
2 files changed, 15 insertions, 1 deletions
diff --git a/ghc/lib/exts/Int.lhs b/ghc/lib/exts/Int.lhs index 88d6b445c7..138d668b33 100644 --- a/ghc/lib/exts/Int.lhs +++ b/ghc/lib/exts/Int.lhs @@ -31,7 +31,8 @@ module Int -- plus Eq, Ord, Num, Bounded, Real, Integral, Ix, Enum, Read, -- Show and Bits instances for each of Int8, Int16, Int32 and Int64 - -- The "official" place to get these from is Addr. + -- The "official" place to get these from is Addr, importing + -- them from Int is a non-standard thing to do. , indexInt8OffAddr , indexInt16OffAddr , indexInt32OffAddr @@ -51,6 +52,9 @@ module Int , sizeofInt16 , sizeofInt32 , sizeofInt64 + + -- non-standard, GHC specific + , intToWord ) where @@ -88,6 +92,10 @@ int16ToInt8 (I16# x) = I8# x int16ToInt32 (I16# x) = I32# x int32ToInt8 (I32# x) = I8# x int32ToInt16 (I32# x) = I16# x + +--GHC specific +intToWord :: Int -> Word +intToWord (I# i#) = W# (int2Word# i#) \end{code} \subsection[Int8]{The @Int8@ interface} diff --git a/ghc/lib/exts/Word.lhs b/ghc/lib/exts/Word.lhs index 5a06a81605..75a4749217 100644 --- a/ghc/lib/exts/Word.lhs +++ b/ghc/lib/exts/Word.lhs @@ -66,6 +66,9 @@ module Word , sizeofWord32 , sizeofWord64 + -- non-standard, GHC specific + , wordToInt + ) where import GlaExts @@ -97,6 +100,9 @@ intToWord32 (I# x) = W32# ((int2Word# x) `and#` (case (maxBound::Word32) of W3 --intToWord32 (I# x) = W32# (int2Word# x) word32ToInt (W32# x) = I# (word2Int# x) +wordToInt :: Word -> Int +wordToInt (W# w#) = I# (word2Int# w#) + \end{code} \subsection[Word8]{The @Word8@ interface} |
