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)