on master help sign in
Add `PrintfArg` instances for `Text` (strict and lazy).
commit93e3705127dc9a01c5216d7462877a27d29f8f01 authorAlois Cochard <alois.cochard@gmail.com> dateWed 12 Aug 2015, 13:31 (11 years ago) parent5747d04
2 files changed+8
Data/Text.hs+4 Data/Text/Lazy.hs+4
Data/Text.hs+4
@@ -237,6 +237,7 @@ import Data.Int (Int64)
237237#if __GLASGOW_HASKELL__ >= 708
238238import qualified GHC.Exts as Exts
239239#endif
240+import Text.Printf (PrintfArg, formatArg, formatString)
240241
241242-- $strict
242243--
@@ -371,6 +372,9 @@ instance Data Text where
371372 _ -> P.error "gunfold"
372373 dataTypeOf _ = textDataType
373374
375+instance PrintfArg Text where
376+ formatArg txt = formatString $ unpack txt
377+
374378packConstr :: Constr
375379packConstr = mkConstr textDataType "pack" [] Prefix
376380
Data/Text/Lazy.hs+4
@@ -237,6 +237,7 @@ import qualified GHC.Base as GHC
237237import qualified GHC.Exts as Exts
238238#endif
239239import GHC.Prim (Addr#)
240+import Text.Printf (PrintfArg, formatArg, formatString)
240241
241242-- $fusion
242243--
@@ -372,6 +373,9 @@ instance Data Text where
372373 _ -> error "Data.Text.Lazy.Text.gunfold"
373374 dataTypeOf _ = textDataType
374375
376+instance PrintfArg Text where
377+ formatArg txt = formatString $ unpack txt
378+
375379packConstr :: Constr
376380packConstr = mkConstr textDataType "pack" [] Prefix
377381