From 5ec22f0135483ea8a8a543c53dcc7f9d7f6a8dea Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Wed, 17 Aug 2022 13:07:31 -0400
Subject: [PATCH] base: Move CString, CStringLen to GHC.Foreign

(cherry picked from commit a1e01a32c6dfe6cb62963ea00e51953e44b8e66a)
---
 libraries/base/Foreign/C/String.hs | 11 +----------
 libraries/base/GHC/Foreign.hs      |  6 +++++-
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/libraries/base/Foreign/C/String.hs b/libraries/base/Foreign/C/String.hs
index a8eb60c5a31e..2b0c7ec25029 100644
--- a/libraries/base/Foreign/C/String.hs
+++ b/libraries/base/Foreign/C/String.hs
@@ -110,20 +110,11 @@ import GHC.Base
 
 import {-# SOURCE #-} GHC.IO.Encoding
 import qualified GHC.Foreign as GHC
+import GHC.Foreign (CString, CStringLen)
 
 -----------------------------------------------------------------------------
 -- Strings
 
--- representation of strings in C
--- ------------------------------
-
--- | A C string is a reference to an array of C characters terminated by NUL.
-type CString    = Ptr CChar
-
--- | A string with explicit length information in bytes instead of a
--- terminating NUL (allowing NUL characters in the middle of the string).
-type CStringLen = (Ptr CChar, Int)
-
 -- exported functions
 -- ------------------
 --
diff --git a/libraries/base/GHC/Foreign.hs b/libraries/base/GHC/Foreign.hs
index 042745ce1108..0bd858190a8a 100644
--- a/libraries/base/GHC/Foreign.hs
+++ b/libraries/base/GHC/Foreign.hs
@@ -19,6 +19,7 @@
 
 module GHC.Foreign (
     -- * C strings with a configurable encoding
+    CString, CStringLen,
 
     -- conversion of C strings into Haskell strings
     --
@@ -74,8 +75,11 @@ putDebugMsg | c_DEBUG_DUMP = debugLn
             | otherwise    = const (return ())
 
 
--- These definitions are identical to those in Foreign.C.String, but copied in here to avoid a cycle:
+-- | A C string is a reference to an array of C characters terminated by NUL.
 type CString    = Ptr CChar
+
+-- | A string with explicit length information in bytes instead of a
+-- terminating NUL (allowing NUL characters in the middle of the string).
 type CStringLen = (Ptr CChar, Int)
 
 -- exported functions
-- 
GitLab