From 7d4a57455b0e0e5a866767bed6e703bbca4c5045 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Tue, 11 Jun 2024 10:51:53 +0100 Subject: [PATCH 1/2] Use TemplateHaskellQuotes rather than TemplateHaskell extension TemplateHaskell can't be used in boot libraries as not all platforms support evaluating Template Haskell splices. Therefore we should use TemplateHaskellQuotes to be more precise about the requirements which a module places on the host system. --- System/OsString/Internal/Types.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/System/OsString/Internal/Types.hs b/System/OsString/Internal/Types.hs index 5cb00b3..390284b 100644 --- a/System/OsString/Internal/Types.hs +++ b/System/OsString/Internal/Types.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PackageImports #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskellQuotes #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeApplications #-} From 6a175fa0a6683d7ae1753e75f8da8984a749e0c5 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 24 Jun 2024 19:11:58 +0800 Subject: [PATCH 2/2] Make OsString Lift instance compatible with GHC-8.10 --- System/OsString/Internal/Types.hs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/System/OsString/Internal/Types.hs b/System/OsString/Internal/Types.hs index 390284b..20e0e55 100644 --- a/System/OsString/Internal/Types.hs +++ b/System/OsString/Internal/Types.hs @@ -46,9 +46,7 @@ import GHC.Generics (Generic) import System.OsString.Encoding.Internal import qualified System.OsString.Data.ByteString.Short as BS import qualified System.OsString.Data.ByteString.Short.Word16 as BS16 -#if MIN_VERSION_template_haskell(2,16,0) import qualified Language.Haskell.TH.Syntax as TH -#endif -- Using unpinned bytearrays to avoid Heap fragmentation and -- which are reasonably cheap to pass to FFI calls @@ -77,8 +75,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 +100,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) @@ -185,7 +181,7 @@ instance Monoid OsString where #if MIN_VERSION_base(4,11,0) mappend = (<>) #else - mappend = coerce (mappend :: BS.ShortByteString -> BS.ShortByteString -> BS.ShortByteString)) + mappend = coerce (mappend :: BS.ShortByteString -> BS.ShortByteString -> BS.ShortByteString) #endif #if MIN_VERSION_base(4,11,0) @@ -197,9 +193,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)