diff --git a/protolude.cabal b/protolude.cabal index b12fa3efd..9c1dfea94 100644 --- a/protolude.cabal +++ b/protolude.cabal @@ -1,114 +1,118 @@ -name: protolude -version: 0.3.0 -synopsis: A small prelude. -description: A sensible set of defaults for writing custom Preludes. -homepage: https://github.com/sdiehl/protolude -license: MIT -license-file: LICENSE -author: Stephen Diehl -maintainer: stephen.m.diehl@gmail.com -copyright: 2016-2020 Stephen Diehl -category: Prelude -build-type: Simple -cabal-version: >=1.10 -bug-reports: https://github.com/sdiehl/protolude/issues -tested-with: - GHC == 7.6.1, - GHC == 7.6.2, - GHC == 7.6.3, - GHC == 7.8.1, - GHC == 7.8.2, - GHC == 7.8.3, - GHC == 7.8.4, - GHC == 7.10.1, - GHC == 7.10.2, - GHC == 7.10.3, - GHC == 8.0.1, - GHC == 8.2.1, - GHC == 8.4.1, - GHC == 8.6.1, - GHC == 8.8.1 - GHC == 8.10.1 -extra-source-files: README.md ChangeLog.md +name: protolude +version: 0.3.0 +synopsis: A small prelude. +description: A sensible set of defaults for writing custom Preludes. +homepage: https://github.com/sdiehl/protolude +license: MIT +license-file: LICENSE +author: Stephen Diehl +maintainer: stephen.m.diehl@gmail.com +copyright: 2016-2020 Stephen Diehl +category: Prelude +build-type: Simple +cabal-version: >=1.10 +bug-reports: https://github.com/sdiehl/protolude/issues +tested-with: + GHC ==7.6.1 + || ==7.6.2 + || ==7.6.3 + || ==7.8.1 + || ==7.8.2 + || ==7.8.3 + || ==7.8.4 + || ==7.10.1 + || ==7.10.2 + || ==7.10.3 + || ==8.0.1 + || ==8.2.1 + || ==8.4.1 + || ==8.6.1 + || ==8.8.1 + || ==8.10.1 + +extra-source-files: + README.md + ChangeLog.md flag dev description: Build development tools - manual: True - default: False + manual: True + default: False -Source-Repository head - type: git - location: git@github.com:protolude/protolude.git +source-repository head + type: git + location: git@github.com:protolude/protolude.git library - exposed-modules: + exposed-modules: Protolude + Protolude.Applicative Protolude.Base - Protolude.Monad - Protolude.Safe - Protolude.List + Protolude.Bifunctor Protolude.Bool - Protolude.Show + Protolude.CallStack Protolude.Conv 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.Either + Protolude.Error + Protolude.Exceptions + Protolude.Functor + Protolude.List + Protolude.Monad + Protolude.Panic + Protolude.Partial + Protolude.Safe + Protolude.Semiring + Protolude.Show Protolude.Unsafe default-extensions: NoImplicitPrelude - OverloadedStrings FlexibleContexts MultiParamTypeClasses + OverloadedStrings - ghc-options: - -Wall - -fwarn-implicit-prelude + ghc-options: -Wall -fwarn-implicit-prelude + build-depends: + 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: - base >= 4.6 && <4.15, - 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 + if !impl(ghc >=8.0) + build-depends: fail ==4.9.* - hs-source-dirs: src - default-language: Haskell2010 + hs-source-dirs: src + default-language: Haskell2010 executable exports - main-is: Exports.hs - default-language: Haskell2010 + main-is: Exports.hs + default-language: Haskell2010 + if flag(dev) buildable: True + else buildable: False + build-depends: - protolude, - base >= 4.6 && <4.15, - ghc, - ghc-paths, - directory, - process, - transformers, - mtl, - filepath + base >=4.6 && <4.15 + , directory + , filepath + , ghc + , ghc-paths + , mtl + , process + , protolude + , transformers diff --git a/src/Protolude.hs b/src/Protolude.hs index 2c0e6401d..8dca6d7b6 100644 --- a/src/Protolude.hs +++ b/src/Protolude.hs @@ -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 #-} diff --git a/src/Protolude/ConvertText.hs b/src/Protolude/ConvertText.hs index ae9b967fe..df3fd26db 100644 --- a/src/Protolude/ConvertText.hs +++ b/src/Protolude/ConvertText.hs @@ -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