diff --git a/.gitignore b/.gitignore index 2856f6d..6bcae34 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ dist cabal.sandbox.config .cabal-sandbox .stack-work +dist-newstyle +.ghc.environment.* diff --git a/.travis.yml b/.travis.yml index 1bcadff..2ff9d50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,150 @@ +# This Travis job script has been generated by a script via +# +# runghc make_travis_yml_2.hs '--output' '.travis.yml' 'text-format.cabal' +# +# For more information, see https://github.com/hvr/multi-ghc-travis +# +language: c sudo: false -env: - - CABALVER=1.18 GHCVER=7.8.4 - - CABALVER=1.22 GHCVER=7.10.1 +git: + submodules: false # whether to recursively clone submodules + +cache: + directories: + - $HOME/.cabal/packages + - $HOME/.cabal/store + +before_cache: + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log + # remove files that are regenerated by 'cabal update' + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.* + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx + + - rm -rfv $HOME/.cabal/packages/head.hackage + +matrix: + include: + - compiler: "ghc-8.6.1" + env: GHCHEAD=true + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.1], sources: [hvr-ghc]}} + - compiler: "ghc-8.4.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}} + - compiler: "ghc-8.2.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}} + - compiler: "ghc-8.0.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.10.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.10.3], sources: [hvr-ghc]}} + - compiler: "ghc-7.8.4" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.8.4], sources: [hvr-ghc]}} + - compiler: "ghc-7.6.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.6.3], sources: [hvr-ghc]}} + - compiler: "ghc-7.4.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.4.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.2.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.2.2], sources: [hvr-ghc]}} + - compiler: "ghc-7.0.4" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.0.4], sources: [hvr-ghc]}} + + allow_failures: + - compiler: "ghc-8.6.1" before_install: - - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH - - travis_retry cabal update + - HC=${CC} + - HCPKG=${HC/ghc/ghc-pkg} + - unset CC + - ROOTDIR=$(pwd) + - mkdir -p $HOME/.local/bin + - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH" + - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') )) + - echo $HCNUMVER install: - - cabal --version - - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" - - cabal install --only-dependencies --enable-tests + - cabal --version + - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" + - BENCH=${BENCH---enable-benchmarks} + - TEST=${TEST---enable-tests} + - HADDOCK=${HADDOCK-true} + - UNCONSTRAINED=${UNCONSTRAINED-true} + - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false} + - GHCHEAD=${GHCHEAD-false} + - travis_retry cabal update -v + - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config" + - rm -fv cabal.project cabal.project.local + # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage + - | + if $GHCHEAD; then + sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config + for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done + + echo 'repository head.hackage' >> ${HOME}/.cabal/config + echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config + echo ' secure: True' >> ${HOME}/.cabal/config + echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config + echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config + echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config + echo ' key-threshold: 3' >> ${HOME}/.cabal.config + + grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' + cabal new-update head.hackage -v + fi + - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' + - "printf 'packages: \".\"\\n' > cabal.project" + - touch cabal.project.local + - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- text-format | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi" + - cat cabal.project || true + - cat cabal.project.local || true + - if [ -f "./configure.ac" ]; then + (cd "." && autoreconf -i); + fi + - rm -f cabal.project.freeze + - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all + - rm -rf .ghc.environment.* "."/dist + - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) + +# Here starts the actual work to be performed for the package under test; +# any command which exits with a non-zero exit code causes the build to fail. script: - - cabal configure --enable-tests -v2 - - cabal build - - cabal test - -addons: - apt: - sources: - - hvr-ghc - packages: - - ghc-7.8.4 - - ghc-7.10.1 - - cabal-install-1.18 - - cabal-install-1.22 + # test that source-distributions can be generated + - (cd "." && cabal sdist) + - mv "."/dist/text-format-*.tar.gz ${DISTDIR}/ + - cd ${DISTDIR} || false + - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; + - "printf 'packages: text-format-*/*.cabal\\n' > cabal.project" + - touch cabal.project.local + - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- text-format | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi" + - cat cabal.project || true + - cat cabal.project.local || true + # this builds all libraries and executables (without tests/benchmarks) + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all + + # build & run tests, build benchmarks + - cabal new-build -w ${HC} ${TEST} ${BENCH} all + + # cabal check + - (cd text-format-* && cabal check) + + # haddock + - rm -rf ./dist-newstyle + - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi + + # Build without installed constraints for packages in global-db + - if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi + +# REGENDATA ["--output",".travis.yml","text-format.cabal"] +# EOF diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0f58f7c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# O.3.2 [Non-maintainer upload] + +- Semigroup-Monoid compatibility (GHC-8.4) diff --git a/Data/Text/Buildable.hs b/Data/Text/Buildable.hs index 4888eb4..7519361 100644 --- a/Data/Text/Buildable.hs +++ b/Data/Text/Buildable.hs @@ -20,11 +20,11 @@ module Data.Text.Buildable import Data.Void (Void, absurd) #endif +import Data.Semigroup ((<>)) import Data.Monoid (mempty) import Data.Int (Int8, Int16, Int32, Int64) import Data.Fixed (Fixed, HasResolution, showFixed) import Data.Ratio (Ratio, denominator, numerator) -import Data.Text.Format.Functions ((<>)) import Data.Text.Format.Int (decimal, hexadecimal) import Data.Text.Format.Types (Hex(..), Shown(..)) import Data.Text.Lazy.Builder diff --git a/Data/Text/Format.hs b/Data/Text/Format.hs index 7a7f725..09f25b7 100644 --- a/Data/Text/Format.hs +++ b/Data/Text/Format.hs @@ -35,8 +35,8 @@ module Data.Text.Format , shortest ) where +import Data.Semigroup ((<>)) import Control.Monad.IO.Class (MonadIO(liftIO)) -import Data.Text.Format.Functions ((<>)) import Data.Text.Format.Params (Params(..)) import Data.Text.Format.Types.Internal (Format(..), Only(..), Shown(..)) import Data.Text.Format.Types.Internal (Hex(..)) diff --git a/Data/Text/Format/Functions.hs b/Data/Text/Format/Functions.hs index f10dd77..78d92c3 100644 --- a/Data/Text/Format/Functions.hs +++ b/Data/Text/Format/Functions.hs @@ -13,7 +13,7 @@ module Data.Text.Format.Functions ( - (<>) + (Data.Text.Format.Functions.<>) , i2d ) where @@ -30,6 +30,7 @@ i2d (I# i#) = C# (chr# (ord# '0'# +# i#)) -- left. (<>) :: Builder -> Builder -> Builder (<>) = mappend +{-# DEPRECATED (<>) "Use <> from Data.Semigroup" #-} {-# INLINE (<>) #-} infixr 4 <> diff --git a/Data/Text/Format/Int.hs b/Data/Text/Format/Int.hs index 37858c9..4bc92bb 100644 --- a/Data/Text/Format/Int.hs +++ b/Data/Text/Format/Int.hs @@ -18,7 +18,8 @@ module Data.Text.Format.Int import Data.Int (Int8, Int16, Int32, Int64) import Data.Monoid (mempty) -import Data.Text.Format.Functions ((<>), i2d) +import Data.Semigroup ((<>)) +import Data.Text.Format.Functions (i2d) import Data.Text.Lazy.Builder import Data.Word (Word, Word8, Word16, Word32, Word64) import GHC.Base (quotInt, remInt) diff --git a/Data/Text/Format/Types/Internal.hs b/Data/Text/Format/Types/Internal.hs index 2eaccb2..b5d837c 100644 --- a/Data/Text/Format/Types/Internal.hs +++ b/Data/Text/Format/Types/Internal.hs @@ -20,6 +20,7 @@ module Data.Text.Format.Types.Internal , Hex(..) ) where +import Data.Semigroup (Semigroup (..)) import Data.Monoid (Monoid(..)) import Data.String (IsString(..)) import Data.Text (Text) @@ -46,9 +47,12 @@ import Data.Typeable (Typeable) newtype Format = Format { fromFormat :: Text } deriving (Eq, Ord, Typeable, Show) +instance Semigroup Format where + Format a <> Format b = Format (a `mappend` b) + instance Monoid Format where - Format a `mappend` Format b = Format (a `mappend` b) mempty = Format mempty + mappend = (<>) instance IsString Format where fromString = Format . fromString diff --git a/text-format.cabal b/text-format.cabal index 78bc4b5..edee4ee 100644 --- a/text-format.cabal +++ b/text-format.cabal @@ -1,5 +1,5 @@ name: text-format -version: 0.3.1.1 +version: 0.3.2 license: BSD3 license-file: LICENSE homepage: https://github.com/bos/text-format @@ -8,7 +8,6 @@ category: Text author: Bryan O'Sullivan maintainer: Bryan O'Sullivan stability: experimental -tested-with: GHC == 7.0.3 synopsis: Text formatting cabal-version: >= 1.8 build-type: Simple @@ -16,8 +15,21 @@ description: A text formatting library optimized for both ease of use and high performance. +tested-with: + GHC == 7.0.4 + || == 7.2.2 + || == 7.4.2 + || == 7.6.3 + || == 7.8.4 + || == 7.10.3 + || == 8.0.2 + || == 8.2.2 + || == 8.4.3 + || == 8.6.1 + extra-source-files: README.markdown + CHANGELOG.md benchmarks/Makefile benchmarks/*.c benchmarks/*.hs @@ -41,7 +53,8 @@ library build-depends: array, - base == 4.*, + base >=4.3 && <4.12, + integer-gmp >= 0.2, double-conversion >= 0.2.0.0, ghc-prim, old-locale, @@ -57,11 +70,9 @@ library cpp-options: -DINTEGER_GMP - if impl(ghc >= 6.11) - build-depends: integer-gmp >= 0.2 - - if impl(ghc >= 6.9) && impl(ghc < 6.11) - build-depends: integer >= 0.1 && < 0.2 + if !impl(ghc >= 8.0) + build-depends: + semigroups >= 0.18.5 && < 0.19 source-repository head type: git