more OsPath conversion (639/749)

Sponsored-by: k0ld
This commit is contained in:
Joey Hess 2025-02-07 16:07:05 -04:00
parent a5d48edd94
commit c74c75b352
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
28 changed files with 147 additions and 132 deletions

View file

@ -8,6 +8,7 @@
-}
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
{-# LANGUAGE CPP #-}
module Utility.Aeson (
module X,
@ -32,6 +33,9 @@ import qualified Data.Vector
import Prelude
import Utility.FileSystemEncoding
#ifdef WITH_OSPATH
import Utility.OsPath
#endif
-- | Use this instead of Data.Aeson.encode to make sure that the
-- below String instance is used.
@ -60,6 +64,11 @@ instance ToJSON' String where
instance ToJSON' S.ByteString where
toJSON' = toJSON . packByteString
#ifdef WITH_OSPATH
instance ToJSON' OsPath where
toJSON' p = toJSON' (fromOsPath p :: S.ByteString)
#endif
-- | Pack a String to Text, correctly handling the filesystem encoding.
--
-- Use this instead of Data.Text.pack.