From 71a84ae8038af796185fab59176f6066a1f45098 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Mon, 20 Jul 1998 10:00:36 +0000
Subject: [PATCH] [project @ 1998-07-20 10:00:34 by sof] non-standard
 extensions: intToWord and wordToInt coercion functions

---
 ghc/lib/exts/Int.lhs  | 10 +++++++++-
 ghc/lib/exts/Word.lhs |  6 ++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ghc/lib/exts/Int.lhs b/ghc/lib/exts/Int.lhs
index 88d6b445c762..138d668b33d6 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 5a06a816058c..75a47492173b 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}
-- 
GitLab