From a9702f0b2bd570504ffc4371026be9250a3e374b Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Mon, 24 Jun 2024 19:11:58 +0800
Subject: [PATCH] Make OsString Lift instance compatible with GHC-8.10

---
 System/OsString/Internal/Types.hs | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/System/OsString/Internal/Types.hs b/System/OsString/Internal/Types.hs
index 390284b..1644bcc 100644
--- a/System/OsString/Internal/Types.hs
+++ b/System/OsString/Internal/Types.hs
@@ -77,8 +77,7 @@ pattern WS { unWS } <- WindowsString unWS where
 
 
 instance Lift WindowsString where
-  lift (WindowsString bs)
-    = [| WindowsString (BS.pack $(lift $ BS.unpack bs)) :: WindowsString |]
+  lift (WindowsString bs) = TH.AppE (TH.ConE 'WindowsString) <$> (lift bs)
 #if MIN_VERSION_template_haskell(2,17,0)
   liftTyped = TH.unsafeCodeCoerce . TH.lift
 #elif MIN_VERSION_template_haskell(2,16,0)
@@ -103,8 +102,7 @@ pattern PS { unPS } <- PosixString unPS where
 #endif
 
 instance Lift PosixString where
-  lift (PosixString bs)
-    = [| PosixString (BS.pack $(lift $ BS.unpack bs)) :: PosixString |]
+  lift (PosixString bs) = TH.AppE (TH.ConE 'PosixString) <$> (lift bs)
 #if MIN_VERSION_template_haskell(2,17,0)
   liftTyped = TH.unsafeCodeCoerce . TH.lift
 #elif MIN_VERSION_template_haskell(2,16,0)
@@ -197,9 +195,9 @@ instance Semigroup OsString where
 instance Lift OsString where
   lift xs = case coercionToPlatformTypes of
     Left (_, co) ->
-      [| OsString (WindowsString (BS.pack $(lift $ BS.unpack $ coerce $ coerceWith co xs))) :: OsString |]
-    Right (_, co) ->
-      [| OsString (PosixString (BS.pack $(lift $ BS.unpack $ coerce $ coerceWith co xs))) :: OsString |]
+      TH.AppE (TH.ConE 'OsString) <$> (lift $ coerceWith co xs)
+    Right (_, co) -> do
+      TH.AppE (TH.ConE 'OsString) <$> (lift $ coerceWith co xs)
 #if MIN_VERSION_template_haskell(2,17,0)
   liftTyped = TH.unsafeCodeCoerce . TH.lift
 #elif MIN_VERSION_template_haskell(2,16,0)