Skip to content

Commit c2dd35c

Browse files
authored
Allow mtl-2.3 and transformers-0.6 (#1150)
Allow `mtl-2.3` and `transformers-0.6`. Some import statements have to be changed to accommodate the breaking changes of `mtl >= 2.3`. In case of `liftM`, I opted for the more modern `<$>`. We also contribute a new CI workflow that tests building with `mtl >= 2.3.1` so that `mtl-2.3` compatibility does not bit-rot.
1 parent 5e893c9 commit c2dd35c

File tree

8 files changed

+75
-10
lines changed

8 files changed

+75
-10
lines changed

.github/workflows/cabal-mtl-2.3.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Cabal build with mtl-2.3
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- ci*
7+
pull_request:
8+
branches:
9+
- master
10+
- ci*
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
build:
18+
name: Build with mtl-2.3
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
22+
steps:
23+
24+
- name: Environment settings based on the Haskell setup
25+
run: |
26+
GHC_VER=$(ghc --numeric-version)
27+
CABAL_VER=$(cabal --numeric-version)
28+
echo "GHC_VER = ${GHC_VER}"
29+
echo "CABAL_VER = ${CABAL_VER}"
30+
echo "GHC_VER=${GHC_VER}" >> "${GITHUB_ENV}"
31+
echo "CABAL_VER=${CABAL_VER}" >> "${GITHUB_ENV}"
32+
33+
# Brotli is already installed on ubuntu-22.04
34+
# - name: Install the brotli library
35+
# run: |
36+
# sudo apt-get update
37+
# sudo apt-get install -y libbrotli-dev
38+
39+
- uses: actions/checkout@v3
40+
41+
- name: Cache build
42+
uses: actions/cache@v3
43+
with:
44+
path: |
45+
~/.cabal
46+
dist-newstyle
47+
key: cabal-${{ env.CABAL_VER }}-ghc-${{ env.GHC_VER }}-commit-${{ github.sha }}
48+
restore-keys: |
49+
cabal-${{ env.CABAL_VER }}-ghc-${{ env.GHC_VER }}-commit-
50+
51+
- name: Prepare cabal
52+
run: |
53+
cabal update
54+
55+
- name: Build dependencies w/o tests with mtl-2.3
56+
# 2022-12-30: 'transformers >= 0.6' is needed because of happstack-server
57+
run: |
58+
cabal build --dependencies-only -O0 --disable-tests --constraint 'mtl >= 2.3.1' --constraint 'transformers >= 0.6' --allow-newer='Cabal:mtl' --allow-newer='Cabal:transformers'
59+
60+
- name: Build w/o tests with mtl-2.3
61+
# 2022-12-30: 'transformers >= 0.6' is needed because of happstack-server
62+
run: |
63+
cabal build -O0 --disable-tests --constraint 'mtl >= 2.3.1' --constraint 'transformers >= 0.6' --allow-newer='Cabal:mtl' --allow-newer='Cabal:transformers'

hackage-server.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ common defaults
106106
, deepseq >= 1.4 && < 1.5
107107
, directory >= 1.3 && < 1.4
108108
, filepath >= 1.4 && < 1.5
109-
, mtl ^>= 2.2.1
109+
, mtl >= 2.2.1 && < 2.4
110110
, pretty >= 1.1 && < 1.2
111111
, process >= 1.6 && < 1.7
112112
, text ^>= 1.2.5.0 || ^>= 2.0
113113
, time >= 1.9 && < 1.13
114-
, transformers >= 0.5 && < 0.6
114+
, transformers >= 0.5 && < 0.7
115115
, unix >= 2.7 && < 2.8
116116
, scientific
117117
-- other dependencies shared by most components

src/Distribution/Server/Features/Browse.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{-# LANGUAGE BlockArguments, NamedFieldPuns #-}
22
module Distribution.Server.Features.Browse (initBrowseFeature, PaginationConfig(..), StartIndex(..), NumElems(..), paginate) where
33

4-
import Control.Monad.Except (ExceptT, liftIO, throwError)
4+
import Control.Monad.Except (ExceptT, throwError)
5+
import Control.Monad.IO.Class (liftIO)
56
import Control.Monad.Trans.Class (lift)
67
import qualified Data.Map as Map
78
import Data.Maybe (isJust)

src/Distribution/Server/Features/Core/Backup.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import qualified Data.Foldable as Foldable
4040
import Data.List
4141
import Data.List.NonEmpty (toList)
4242
import Data.Ord (comparing)
43-
import Control.Monad.State
43+
import Control.Monad
4444
import qualified Distribution.Server.Util.GZip as GZip
4545
import qualified Data.ByteString.Lazy as BS
4646
import qualified Data.ByteString.Lazy.Char8 as BSC

src/Distribution/Server/Features/Security/Backup.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Distribution.Server.Features.Security.Backup (
66
) where
77

88
-- stdlib
9-
import Control.Monad.State
9+
import Control.Monad.State (StateT, execStateT, modify)
1010
import Data.Time
1111
import Data.Version (Version(..), showVersion)
1212
import Text.CSV hiding (csv)
@@ -224,7 +224,7 @@ import_v1 = mapM_ fromRecord
224224
fromInfoRecord [strFileLength, strSHA256, strMD5] = do
225225
fileInfoLength <- parseRead "file length" strFileLength
226226
fileInfoSHA256 <- parseSHA "file SHA256" strSHA256
227-
fileInfoMD5 <- Just `liftM` parseMD5 "file MD5" strMD5
227+
fileInfoMD5 <- Just <$> parseMD5 "file MD5" strMD5
228228
return FileInfo{..}
229229
fromInfoRecord otherRecord =
230230
fail $ "Unexpected info record: " ++ show otherRecord

src/Distribution/Server/Features/Security/State.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
module Distribution.Server.Features.Security.State where
88

99
-- stdlib
10-
import Control.Monad.Reader
10+
import Control.Monad
11+
import Control.Monad.Reader (ask, asks)
1112
import Data.Acid
1213
import Data.Maybe
1314
import Data.SafeCopy

src/Distribution/Server/Framework/BackupRestore.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import Distribution.Server.Features.Security.SHA256
5151
import qualified Codec.Archive.Tar as Tar
5252
import qualified Codec.Archive.Tar.Entry as Tar
5353
import Distribution.Server.Util.GZip (decompressNamed)
54-
import Control.Monad.State
55-
import Control.Monad.Except
54+
import Control.Monad.State (StateT, evalStateT, MonadState, get, gets, put)
55+
import Control.Monad.Except (ExceptT, runExceptT, MonadError(..))
5656
import Data.Time (UTCTime)
5757
import qualified Data.Time as Time
5858
import Data.Time.Format (defaultTimeLocale)

src/Distribution/Server/Util/Markdown.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import qualified Data.Text.Encoding.Error as T (lenientDecode)
2222
import qualified Data.Text.Lazy as TL
2323
import Data.Typeable (Typeable)
2424
import Network.URI (isRelativeReference)
25-
import Control.Monad.Identity
25+
import Control.Monad.Identity (runIdentity)
2626
import Text.HTML.SanitizeXSS as XSS
2727
import System.FilePath.Posix (takeExtension)
2828
import qualified Data.ByteString.Lazy as BS (ByteString, toStrict)

0 commit comments

Comments
 (0)