Migrate show to use Conv.StringConv

This commit is contained in:
sdiehl
2020-04-25 11:58:41 +01:00
parent 8ff8b7ae49
commit 9309ca3107
3 changed files with 99 additions and 88 deletions
+3 -2
View File
@@ -153,6 +153,7 @@ import Protolude.ConvertText as ConvertText
import Protolude.Panic as Panic
import Protolude.Exceptions as Exception
import Protolude.Semiring as Semiring
import qualified Protolude.Conv as Conv
import Protolude.Base as Base hiding (
putStr -- Overriden by Show.putStr
@@ -982,8 +983,8 @@ liftIO1 = (.) liftIO
liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c
liftIO2 = ((.).(.)) liftIO
show :: (Show a, ConvertText String b) => a -> b
show x = ConvertText.toS (PBase.show x)
show :: (Show a, Conv.StringConv String b) => a -> b
show x = Conv.toS (PBase.show x)
{-# SPECIALIZE show :: Show a => a -> Text #-}
{-# SPECIALIZE show :: Show a => a -> LText #-}
{-# SPECIALIZE show :: Show a => a -> String #-}
+6
View File
@@ -35,6 +35,12 @@ instance ConvertText LT.Text String where toS = LT.unpack
instance ConvertText LT.Text T.Text where toS = LT.toStrict
instance ConvertText LT.Text LT.Text where toS = id
instance ConvertText LB.ByteString B.ByteString where toS = LB.toStrict
instance ConvertText LB.ByteString LB.ByteString where toS = id
instance ConvertText B.ByteString B.ByteString where toS = id
instance ConvertText B.ByteString LB.ByteString where toS = LB.fromStrict
toUtf8 :: ConvertText a T.Text => a -> B.ByteString
toUtf8 =
encodeUtf8 . toS