Merge pull request #118 from protolude/strconv

Migrate show to use Conv.StringConv
This commit is contained in:
Stephen Diehl
2020-05-04 16:08:54 +01:00
committed by GitHub
3 changed files with 99 additions and 88 deletions
+90 -86
View File
@@ -1,114 +1,118 @@
name: protolude name: protolude
version: 0.3.0 version: 0.3.0
synopsis: A small prelude. synopsis: A small prelude.
description: A sensible set of defaults for writing custom Preludes. description: A sensible set of defaults for writing custom Preludes.
homepage: https://github.com/sdiehl/protolude homepage: https://github.com/sdiehl/protolude
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Stephen Diehl author: Stephen Diehl
maintainer: stephen.m.diehl@gmail.com maintainer: stephen.m.diehl@gmail.com
copyright: 2016-2020 Stephen Diehl copyright: 2016-2020 Stephen Diehl
category: Prelude category: Prelude
build-type: Simple build-type: Simple
cabal-version: >=1.10 cabal-version: >=1.10
bug-reports: https://github.com/sdiehl/protolude/issues bug-reports: https://github.com/sdiehl/protolude/issues
tested-with: tested-with:
GHC == 7.6.1, GHC ==7.6.1
GHC == 7.6.2, || ==7.6.2
GHC == 7.6.3, || ==7.6.3
GHC == 7.8.1, || ==7.8.1
GHC == 7.8.2, || ==7.8.2
GHC == 7.8.3, || ==7.8.3
GHC == 7.8.4, || ==7.8.4
GHC == 7.10.1, || ==7.10.1
GHC == 7.10.2, || ==7.10.2
GHC == 7.10.3, || ==7.10.3
GHC == 8.0.1, || ==8.0.1
GHC == 8.2.1, || ==8.2.1
GHC == 8.4.1, || ==8.4.1
GHC == 8.6.1, || ==8.6.1
GHC == 8.8.1 || ==8.8.1
GHC == 8.10.1 || ==8.10.1
extra-source-files: README.md ChangeLog.md
extra-source-files:
README.md
ChangeLog.md
flag dev flag dev
description: Build development tools description: Build development tools
manual: True manual: True
default: False default: False
Source-Repository head source-repository head
type: git type: git
location: git@github.com:protolude/protolude.git location: git@github.com:protolude/protolude.git
library library
exposed-modules: exposed-modules:
Protolude Protolude
Protolude.Applicative
Protolude.Base Protolude.Base
Protolude.Monad Protolude.Bifunctor
Protolude.Safe
Protolude.List
Protolude.Bool Protolude.Bool
Protolude.Show Protolude.CallStack
Protolude.Conv Protolude.Conv
Protolude.ConvertText Protolude.ConvertText
Protolude.Either
Protolude.Functor
Protolude.Semiring
Protolude.Bifunctor
Protolude.Applicative
Protolude.Error
Protolude.Panic
Protolude.CallStack
Protolude.Exceptions
Protolude.Partial
Protolude.Debug Protolude.Debug
Protolude.Either
Protolude.Error
Protolude.Exceptions
Protolude.Functor
Protolude.List
Protolude.Monad
Protolude.Panic
Protolude.Partial
Protolude.Safe
Protolude.Semiring
Protolude.Show
Protolude.Unsafe Protolude.Unsafe
default-extensions: default-extensions:
NoImplicitPrelude NoImplicitPrelude
OverloadedStrings
FlexibleContexts FlexibleContexts
MultiParamTypeClasses MultiParamTypeClasses
OverloadedStrings
ghc-options: ghc-options: -Wall -fwarn-implicit-prelude
-Wall build-depends:
-fwarn-implicit-prelude array >=0.4 && <0.6
, async >=2.0 && <2.3
, base >=4.6 && <4.15
, bytestring >=0.10 && <0.11
, containers >=0.5 && <0.7
, deepseq >=1.3 && <1.5
, ghc-prim >=0.3 && <0.7
, hashable >=1.2 && <1.4
, mtl >=2.1 && <2.3
, mtl-compat >=0.2 && <0.3
, stm >=2.4 && <2.6
, text >=1.2 && <1.3
, transformers >=0.2 && <0.6
, transformers-compat >=0.4 && <0.7
build-depends: if !impl(ghc >=8.0)
base >= 4.6 && <4.15, build-depends: fail ==4.9.*
array >= 0.4 && <0.6,
ghc-prim >= 0.3 && <0.7,
async >= 2.0 && <2.3,
deepseq >= 1.3 && <1.5,
containers >= 0.5 && <0.7,
hashable >= 1.2 && <1.4,
transformers >= 0.2 && <0.6,
text >= 1.2 && <1.3,
stm >= 2.4 && <2.6,
bytestring >= 0.10 && <0.11,
mtl >= 2.1 && <2.3,
mtl-compat >= 0.2 && <0.3,
transformers-compat >= 0.4 && <0.7
if !impl(ghc >= 8.0)
Build-Depends: fail >= 4.9 && <4.10
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010
executable exports executable exports
main-is: Exports.hs main-is: Exports.hs
default-language: Haskell2010 default-language: Haskell2010
if flag(dev) if flag(dev)
buildable: True buildable: True
else else
buildable: False buildable: False
build-depends: build-depends:
protolude, base >=4.6 && <4.15
base >= 4.6 && <4.15, , directory
ghc, , filepath
ghc-paths, , ghc
directory, , ghc-paths
process, , mtl
transformers, , process
mtl, , protolude
filepath , transformers
+3 -2
View File
@@ -153,6 +153,7 @@ import Protolude.ConvertText as ConvertText
import Protolude.Panic as Panic import Protolude.Panic as Panic
import Protolude.Exceptions as Exception import Protolude.Exceptions as Exception
import Protolude.Semiring as Semiring import Protolude.Semiring as Semiring
import qualified Protolude.Conv as Conv
import Protolude.Base as Base hiding ( import Protolude.Base as Base hiding (
putStr -- Overriden by Show.putStr putStr -- Overriden by Show.putStr
@@ -982,8 +983,8 @@ liftIO1 = (.) liftIO
liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c liftIO2 :: MonadIO m => (a -> b -> IO c) -> a -> b -> m c
liftIO2 = ((.).(.)) liftIO liftIO2 = ((.).(.)) liftIO
show :: (Show a, ConvertText String b) => a -> b show :: (Show a, Conv.StringConv String b) => a -> b
show x = ConvertText.toS (PBase.show x) show x = Conv.toS (PBase.show x)
{-# SPECIALIZE show :: Show a => a -> Text #-} {-# SPECIALIZE show :: Show a => a -> Text #-}
{-# SPECIALIZE show :: Show a => a -> LText #-} {-# SPECIALIZE show :: Show a => a -> LText #-}
{-# SPECIALIZE show :: Show a => a -> String #-} {-# 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 T.Text where toS = LT.toStrict
instance ConvertText LT.Text LT.Text where toS = id 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 :: ConvertText a T.Text => a -> B.ByteString
toUtf8 = toUtf8 =
encodeUtf8 . toS encodeUtf8 . toS