Skip to content

Commit

Permalink
Updates for GHC 8.8 (#62)
Browse files Browse the repository at this point in the history
checks off the `base-4.13.0.0` box in #24.
  • Loading branch information
RyanGlScott authored May 22, 2019
1 parent bbd7abc commit 8a24328
Show file tree
Hide file tree
Showing 19 changed files with 209 additions and 99 deletions.
57 changes: 28 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.3.20190429
# version: 0.3.20190521
#
# This file is patched:
# - We install the typediff utility from its repoistory.
Expand Down Expand Up @@ -34,6 +34,9 @@ before_cache:
- rm -rfv $CABALHOME/packages/head.hackage
matrix:
include:
- compiler: ghc-8.8.1
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}
env: GHCHEAD=true
- compiler: ghc-8.6.5
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}
- compiler: ghc-8.6.4
Expand Down Expand Up @@ -99,6 +102,8 @@ matrix:
- compiler: ghc-7.0.1
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.1","cabal-install-2.4"]}}
env: BATTERIES=NO
allow_failures:
- compiler: ghc-8.8.1
before_install:
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
- HCPKG="$HC-pkg"
Expand All @@ -107,32 +112,14 @@ before_install:
- CABALHOME=$HOME/.cabal
# install typediff
- mkdir -p $HOME/.local/bin
- curl -L https://github.com/haskell-compat/base-compat/releases/download/typediff-0.1.3/typediff > $HOME/.local/bin/typediff
- curl -L https://github.com/haskell-compat/base-compat/releases/download/typediff-0.1.4/typediff > $HOME/.local/bin/typediff
- chmod +x $HOME/.local/bin/typediff
- export PATH="/opt/ghc/bin:$CABALHOME/bin:$HOME/.local/bin:$PATH"
- TOP=$(pwd)
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
- echo $HCNUMVER
- CABAL="$CABAL -vnormal+nowrap+markoutput"
- set -o pipefail
- |
echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
echo 'BEGIN { state = "output"; }' >> .colorful.awk
echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
echo ' if (state == "cabal") {' >> .colorful.awk
echo ' print blue($0)' >> .colorful.awk
echo ' } else {' >> .colorful.awk
echo ' print $0' >> .colorful.awk
echo ' }' >> .colorful.awk
echo '}' >> .colorful.awk
- cat .colorful.awk
- |
color_cabal_output () {
awk -f $TOP/.colorful.awk
}
- echo text | color_cabal_output
install:
- ${CABAL} --version
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
Expand All @@ -156,6 +143,18 @@ install:
echo " prefix: $CABALHOME" >> $CABALHOME/config
echo "repository hackage.haskell.org" >> $CABALHOME/config
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
- |
if $GHCHEAD; then
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config
echo "repository head.hackage" >> $CABALHOME/config
echo " url: http://head.hackage.haskell.org/" >> $CABALHOME/config
echo " secure: True" >> $CABALHOME/config
echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config
echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config
echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config
echo " key-threshold: 3" >> $CABALHOME/config
fi
- cat $CABALHOME/config
- rm -fv cabal.project cabal.project.local cabal.project.freeze
- travis_retry ${CABAL} v2-update -v
Expand All @@ -173,15 +172,15 @@ install:
- if [ -f "./base-compat/configure.ac" ]; then (cd "./base-compat" && autoreconf -i); fi
- if [ -f "./base-compat-batteries/configure.ac" ]; then (cd "./base-compat-batteries" && autoreconf -i); fi
- if [ -f "./check/configure.ac" ]; then (cd "./check" && autoreconf -i); fi
- ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output
- ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH}
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
- rm cabal.project.freeze
- travis_wait ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
- travis_wait ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
- travis_wait ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
- travis_wait ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
script:
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# Packaging...
- ${CABAL} v2-sdist all | color_cabal_output
- ${CABAL} v2-sdist all
# Unpacking...
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
- cd ${DISTDIR} || false
Expand All @@ -199,21 +198,21 @@ script:
- cat cabal.project.local || true
# Building...
# this builds all libraries and executables (without tests/benchmarks)
- ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
- ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all
# Building with tests and benchmarks...
# build & run tests, build benchmarks
- ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
- ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all
# Testing...
- if [ $HCNUMVER -ge 70002 ] && [ $HCNUMVER -lt 70201 ] || [ $HCNUMVER -ge 70202 ] && [ $HCNUMVER -lt 70401 ] || [ $HCNUMVER -ge 70402 ] && [ $HCNUMVER -lt 70801 ] || [ $HCNUMVER -ge 70802 ] ; then ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output ; fi
- if [ $HCNUMVER -ge 70002 ] && [ $HCNUMVER -lt 70201 ] || [ $HCNUMVER -ge 70202 ] && [ $HCNUMVER -lt 70401 ] || [ $HCNUMVER -ge 70402 ] && [ $HCNUMVER -lt 70801 ] || [ $HCNUMVER -ge 70802 ] ; then ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all ; fi
# cabal check...
- (cd base-compat-* && ${CABAL} -vnormal check)
- if [ ! "x$BATTERIES" = "xNO" ] ; then (cd base-compat-batteries-* && ${CABAL} -vnormal check) ; fi
- if [ ! "x$BATTERIES" = "xNO" ] ; then (cd type-check-* && ${CABAL} -vnormal check) ; fi
# haddock...
- ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
- ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all
# Building without installed constraints for packages in global-db...
- rm -f cabal.project.local
- ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
- ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all

# REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]
# EOF
33 changes: 33 additions & 0 deletions base-compat-batteries/CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
## Changes in 0.11.0 [????.??.??]
- Reexport `MonadFail(fail)` from `Prelude.Compat` and `Control.Monad.Compat`.

Because `Prelude.Compat.fail` now corresponds to the `fail` from `MonadFail`
instead of `Monad`, some care is required to implement `Monad.fail` on
pre-8.8 versions of GHC. The following template is recommended:

```haskell
import Prelude.Compat
#if !(MIN_VERSION_base(4,13,0))
import qualified Control.Monad
#endif

data Blah a = ...

instance Functor Blah where ...
instance Applicative Blah where ...

instance Monad Blah where
(>>=) = ...
#if !(MIN_VERSION_base(4,13,0))
fail = fail -- The RHS fail corresponds to MonadFail.fail,
-- /not/ Monad.fail
#endif

instance MonadFail Blah where
fail = ...
```

- This coincides with the `base-compat-???` release. Refer to the
[`base-compat` changelog](https://github.com/haskell-compat/base-compat/blob/master/base-compat/CHANGES.markdown#changes-in-????-????????)
for more details.

## Changes in 0.10.5 [2018.10.18]
- This coincides with the `base-compat-0.10.5` release. Refer to the
[`base-compat` changelog](https://github.com/haskell-compat/base-compat/blob/master/base-compat/CHANGES.markdown#changes-in-0105-20181018)
Expand Down
5 changes: 3 additions & 2 deletions base-compat-batteries/base-compat-batteries.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: base-compat-batteries
version: 0.10.5
version: 0.11.0
license: MIT
license-file: LICENSE
copyright: (c) 2012-2018 Simon Hengel,
Expand Down Expand Up @@ -44,6 +44,7 @@ tested-with: GHC == 7.0.*
, GHC == 8.2.*
, GHC == 8.4.*
, GHC == 8.6.*
, GHC == 8.8.*
extra-source-files: CHANGES.markdown, README.markdown

source-repository head
Expand All @@ -56,7 +57,7 @@ library
-Wall
build-depends:
base >= 4.3 && < 5,
base-compat == 0.10.5
base-compat == 0.11.0
if !impl(ghc >= 7.8)
build-depends:
tagged >= 0.8.5 && < 0.9
Expand Down
6 changes: 4 additions & 2 deletions base-compat-batteries/src/Control/Monad/Compat.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE CPP, NoImplicitPrelude, PackageImports #-}
module Control.Monad.Compat (
module Base
) where
, fail
) where

import "base-compat" Control.Monad.Compat as Base
import "base-compat" Control.Monad.Compat as Base hiding (fail)
import Control.Monad.Fail (fail)
5 changes: 5 additions & 0 deletions base-compat-batteries/src/Prelude/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
module Prelude.Compat (
module Base
#if !(MIN_VERSION_base(4,9,0))
, Fail.MonadFail(Fail.fail)
, Semi.Semigroup((Semi.<>))
#endif
) where

import "base-compat" Prelude.Compat as Base
#if !(MIN_VERSION_base(4,9,0))
hiding (fail)
#endif

#if !(MIN_VERSION_base(4,9,0))
import "fail" Control.Monad.Fail as Fail
import "semigroups" Data.Semigroup as Semi
#endif
38 changes: 38 additions & 0 deletions base-compat/CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## Changes in 0.11.0 [????.??.??]
- Sync with `base-4.13`/GHC 8.8
- Backport `MonadFail(fail)` to `Prelude.Compat` and `Control.Monad.Compat`.

Because `Prelude.Compat.fail` now corresponds to the `fail` from `MonadFail`
instead of `Monad`, some care is required to implement `Monad.fail` on
pre-8.8 versions of GHC. The following template is recommended:

```haskell
import Prelude.Compat
#if !(MIN_VERSION_base(4,13,0))
import qualified Control.Monad
#endif

data Blah a = ...

instance Functor Blah where ...
instance Applicative Blah where ...

instance Monad Blah where
(>>=) = ...
#if !(MIN_VERSION_base(4,13,0))
fail = fail -- The RHS fail corresponds to MonadFail.fail,
-- /not/ Monad.fail
#endif

instance MonadFail Blah where
fail = ...
```

Note that the `MonadFail` class has only been in `base` since
`base-4.9`/GHC 8.0, so accordingly, this can only be backported back
to GHC 8.0. If you wish to have a version of
`Prelude.Compat`/`Control.Monad.Compat` that backports
`MonadFail` to older GHCs (by conditionally depending on the `fail`
library), use the `Prelude.Compat`/`Control.Monad.Compat` modules from the
`base-compat-batteries` package.

## Changes in 0.10.5 [2018.10.18]
- Enable `BangPatterns` in `Prelude.Compat`.

Expand Down
2 changes: 2 additions & 0 deletions base-compat/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ on, paired with the things that each library backports:

## Supported versions of GHC/`base`

* `ghc-8.8.1` / `base-4.13.0.0`
* `ghc-8.6.5` / `base-4.12.0.0`
* `ghc-8.6.4` / `base-4.12.0.0`
* `ghc-8.6.3` / `base-4.12.0.0`
* `ghc-8.6.2` / `base-4.12.0.0`
Expand Down
3 changes: 2 additions & 1 deletion base-compat/base-compat.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: base-compat
version: 0.10.5
version: 0.11.0
license: MIT
license-file: LICENSE
copyright: (c) 2012-2018 Simon Hengel,
Expand Down Expand Up @@ -53,6 +53,7 @@ tested-with: GHC == 7.0.*
, GHC == 8.2.*
, GHC == 8.4.*
, GHC == 8.6.*
, GHC == 8.8.*
extra-source-files: CHANGES.markdown, README.markdown

source-repository head
Expand Down
9 changes: 7 additions & 2 deletions base-compat/src/Control/Monad/Compat.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{-# LANGUAGE CPP, NoImplicitPrelude #-}
module Control.Monad.Compat (
module Base
, Monad(..)
, Monad
#if MIN_VERSION_base(4,9,0)
, MonadFail
#endif
, fail
, MonadPlus(..)
#if !(MIN_VERSION_base(4,8,0))
, foldM
Expand Down Expand Up @@ -31,7 +35,8 @@ module Control.Monad.Compat (
) where

#if MIN_VERSION_base(4,9,0)
import Control.Monad as Base
import Control.Monad as Base hiding (fail)
import Control.Monad.Fail as Base
#else
import Control.Monad as Base hiding (
forever
Expand Down
17 changes: 14 additions & 3 deletions base-compat/src/Prelude/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ module Prelude.Compat (
, Functor
, Integral
, Monad
#if MIN_VERSION_base(4,9,0)
, MonadFail
#endif
, Monoid
, Num (fromInteger)
, Ord
Expand Down Expand Up @@ -274,10 +277,14 @@ module Prelude.Compat (

#if MIN_VERSION_base(4,9,0)

import Prelude as Base
# if MIN_VERSION_base(4,10,0) && !(MIN_VERSION_base(4,12,0))
hiding (($!))
import Prelude as Base hiding (
# if !(MIN_VERSION_base(4,13,0))
fail
# if MIN_VERSION_base(4,10,0) && !(MIN_VERSION_base(4,12,0))
, ($!)
# endif
# endif
)

#else

Expand Down Expand Up @@ -322,6 +329,10 @@ import Data.Word
import Data.Semigroup as Base (Semigroup((<>)))
#endif

#if MIN_VERSION_base(4,9,0) && !(MIN_VERSION_base(4,13,0))
import Control.Monad.Fail as Base (MonadFail(fail))
#endif

#if MIN_VERSION_base(4,10,0) && !(MIN_VERSION_base(4,12,0))
import GHC.Exts (TYPE)
#endif
Expand Down
2 changes: 2 additions & 0 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ env: 7.0.1:BATTERIES=NO,
-- TODO: Have `BATTERIES=NO` imply no tests
tests: (>=7.0.2 && <7.2.1) || (>=7.2.2 && <7.4.1) || (>=7.4.2 && <7.8.1) || >=7.8.2
travis-patches: travis.yml.patch
-- travis_wait interacts poorly with color_cabal_output
color: False
3 changes: 2 additions & 1 deletion check/lib/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ normalizeSignatures
-- something that we shouldn't.
--
_ <- P.choice
[ P.try (P.string "ghc-prim")
[ P.try (P.string "fail")
, P.try (P.string "ghc-prim")
, P.try (P.string "semigroups")
]

Expand Down
5 changes: 3 additions & 2 deletions check/type-check.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 0.1.0
synopsis: Checks that exported type signatures match what's expected
description:
Checks that exported type signatures match what's expected.


author: Simon Hengel <sol@typeful.net>,
João Cristóvão <jmacristovao@gmail.com>,
Expand Down Expand Up @@ -38,6 +38,7 @@ tested-with: GHC == 7.0.*
, GHC == 8.2.*
, GHC == 8.4.*
, GHC == 8.6.*
, GHC == 8.8.*
library
exposed-modules:
TypeDump
Expand Down Expand Up @@ -75,7 +76,7 @@ executable dumptypes

-- Run with
-- (cd check && cabal new-run dumpindex Control.Monad.Compat)
--
--
executable dumpindex
default-language: Haskell2010
hs-source-dirs: exes
Expand Down
Loading

0 comments on commit 8a24328

Please sign in to comment.