Skip to content

Commit

Permalink
Merge pull request #62 from andreasabel/ghc-9
Browse files Browse the repository at this point in the history
Port to Cabal >= 3.4 and GHC >= 9.0
  • Loading branch information
snoyberg authored Mar 25, 2024
2 parents 53f625a + 45fa55e commit 3dab7c2
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 70 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Stack build

on:
push:
branches: [web]
pull_request:
branches: [web]

jobs:
build:
name: Stack ${{ matrix.ghc }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ghc: ['9.8', '9.6', '9.4', '9.2', '9.0']

steps:
- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
cabal-update: false

- name: Restore cache
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-stack-${{ steps.setup.outputs.stack-version }}-ghc-${{ steps.setup.outputs.ghc-version }}
with:
path: |
${{ steps.setup.outputs.stack-root }}
.stack-work
key: ${{ env.key }}-commit-${{ github.sha }}
restore-keys: ${{ env.key }}-

- name: Build dependencies
run: stack build --stack-yaml=stack-${{ matrix.ghc }}.yaml --system-ghc --only-dependencies

- name: Build
run: stack build --stack-yaml=stack-${{ matrix.ghc }}.yaml --system-ghc

- name: Save cache
uses: actions/cache/save@v4
if: always()
with:
key: ${{ steps.cache.outputs.cache-primary-key }}
path: |
${{ steps.setup.outputs.stack-root }}
.stack-work
8 changes: 4 additions & 4 deletions packdeps-cli/packdeps.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ extra-source-files: README.md ChangeLog.md
library
default-language: Haskell2010
hs-source-dirs: src
build-depends: base >= 4.14 && < 5
build-depends: base >= 4.15 && < 5
, tar >= 0.4 && < 0.6
, split >= 0.1.2.3
, bytestring >= 0.9
, text >= 0.7
, Cabal >= 3.2 && < 3.3
, Cabal >= 3.4
, time >= 1.1.4
, containers >= 0.2
, directory >= 1.0
Expand All @@ -39,9 +39,9 @@ executable packdeps

ghc-options: -Wall -rtsopts

build-depends: base >= 4.14 && < 5
build-depends: base
, Cabal
, optparse-applicative >=0.14 && <0.17
, optparse-applicative >=0.14
, containers
, semigroups
, process
Expand Down
10 changes: 5 additions & 5 deletions packdeps-cli/src/Distribution/PackDeps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Distribution.PackDeps
( -- * Data types
Newest
, CheckDepsRes (..)
, DescInfo
, DescInfo (..)
-- * Read package database
, loadNewest
, loadNewestFrom
Expand All @@ -28,7 +28,6 @@ module Distribution.PackDeps
-- * Internal
, PackInfo (..)
, piRevision
, DescInfo (..)
) where

import Control.Applicative as A ((<$>))
Expand All @@ -46,7 +45,6 @@ import Distribution.PackageDescription
import Distribution.PackageDescription.Parsec
import Distribution.Parsec (Parsec, lexemeParsec, runParsecParser, simpleParsec)
import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)
import Distribution.Types.CondTree
import Distribution.Version
import Distribution.Utils.ShortText
import qualified Distribution.Utils.ShortText as ShortText
Expand Down Expand Up @@ -252,7 +250,9 @@ getLibDeps gpd = maybe [] condTreeConstraints' (condLibrary gpd) ++ customDeps

-- we only interested in Cabal default upper bound
-- See cabal-install Distribution.Client.ProjectPlanning defaultSetupDeps
defSetupDeps = [Dependency (mkPackageName "Cabal") (earlierVersion $ mkVersion [1,25]) mempty]
defSetupDeps = [Dependency (mkPackageName "Cabal") (earlierVersion $ mkVersion [1,25])
mainLibSet
]

condTreeConstraints' :: Monoid c => CondTree ConfVar c a -> c
condTreeConstraints' = go where
Expand All @@ -265,7 +265,7 @@ condTreeConstraints' = go where
notFlagCondition :: Condition ConfVar -> Bool
notFlagCondition (Var (OS _)) = True
notFlagCondition (Var (Arch _)) = True
notFlagCondition (Var (Flag _)) = False
notFlagCondition (Var (PackageFlag _)) = False
notFlagCondition (Var (Impl _ _)) = True
notFlagCondition (Lit _) = True
notFlagCondition (CNot a) = notFlagCondition a
Expand Down
15 changes: 9 additions & 6 deletions packdeps-yesod/packdeps-yesod.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal-version: >= 1.10
name: packdeps-yesod
version: 0.0.0
license: BSD3
Expand All @@ -8,7 +9,6 @@ synopsis: The greatest Yesod web application ever.
description: I'm sure you can say something clever here if you try.
category: Web
stability: Experimental
cabal-version: >= 1.8
build-type: Simple
homepage: http://packdeps.yesodweb.com/

Expand Down Expand Up @@ -40,7 +40,9 @@ library
else
ghc-options: -Wall -threaded -O2

extensions: TemplateHaskell
default-language: Haskell2010
default-extensions:
TemplateHaskell
QuasiQuotes
OverloadedStrings
NoImplicitPrelude
Expand All @@ -54,7 +56,7 @@ library
NoMonomorphismRestriction
ViewPatterns

build-depends: base >= 4 && < 5
build-depends: base >= 4.15 && < 5
, yesod >= 1.2
, yesod-core >= 1.2
, yesod-static >= 1.2
Expand All @@ -71,11 +73,11 @@ library
, directory >= 1.1
, warp >= 1.3
, http-conduit
, http-client
, http-client >= 0.5.0
, http-client-tls
, conduit >= 0.5
, time
, Cabal >= 3.2 && < 3.3
, Cabal >= 3.4
, containers
, deepseq
, tar
Expand All @@ -101,4 +103,5 @@ executable packdeps-server
build-depends: base
, packdeps-yesod
, yesod
ghc-options: -Wall -threaded -O2
ghc-options: -Wall -threaded -O2
default-language: Haskell2010
4 changes: 0 additions & 4 deletions packdeps-yesod/src/Application.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ loadData update' = do
hFlush stderr
log "Entered loadData"
req' <- parseUrlThrow "http://hackage.haskell.org/01-index.tar.gz"
#if MIN_VERSION_http_client(0,5,0)
let req = req' { responseTimeout = responseTimeoutMicro 30000000 }
#else
let req = req' { responseTimeout = Just 30000000 }
#endif
forever $ do
log "In forever"
res <- try $ do
Expand Down
7 changes: 3 additions & 4 deletions packdeps-yesod/src/Distribution/PackDeps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ import qualified Distribution.Utils.ShortText as ShortText

import Distribution.Package hiding (PackageName)
import qualified Distribution.Package as D
import Distribution.PackageDescription
import Distribution.PackageDescription hiding (PackageName)
import Distribution.PackageDescription.Parsec
import Distribution.Pretty (prettyShow)
import Distribution.Types.CondTree (CondBranch (..))
import qualified Distribution.Version as D
import Distribution.Text hiding (Text)
import Distribution.Text

import qualified Data.Text as TS
import qualified Data.ByteString.Lazy as L
Expand Down Expand Up @@ -247,7 +246,7 @@ getDeps gpd = HMap.map (fmap convertVersionRange)

checkCond' _ (Var (OS _)) = True
checkCond' _ (Var (Arch _)) = True
checkCond' flagMap (Var (Flag f)) = fromMaybe False $ Map.lookup f flagMap
checkCond' flagMap (Var (PackageFlag f)) = fromMaybe False $ Map.lookup f flagMap
checkCond' _ (Var (Impl _compiler _range)) = True
checkCond' _ (Lit b) = b
checkCond' flagMap (CNot c) = not $ checkCond' flagMap c
Expand Down
29 changes: 12 additions & 17 deletions packdeps-yesod/src/Distribution/PackDeps/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import GHC.Generics
import Distribution.Text (display)
import qualified Distribution.Types.PackageName as D
import qualified Distribution.Version as D
import qualified Distribution.Types.VersionRange.Internal as D
import Data.Vector ((!))

import Data.Binary (Binary (..), putWord8, getWord8, Put, Get)
Expand Down Expand Up @@ -187,7 +186,6 @@ newestToIds (Newest newest) =
goVR (WildcardVersion v) = WildcardVersion <$> getVersion v
goVR (UnionVersionRanges x y) = UnionVersionRanges <$> goVR x <*> goVR y
goVR (IntersectVersionRanges x y) = IntersectVersionRanges <$> goVR x <*> goVR y
goVR (VersionRangeParens x) = VersionRangeParens <$> goVR x
goVR (MajorBoundVersion x) = MajorBoundVersion <$> getVersion x
goVR (OrLaterVersion x) = OrLaterVersion <$> getVersion x
goVR (OrEarlierVersion x) = OrEarlierVersion <$> getVersion x
Expand Down Expand Up @@ -220,7 +218,6 @@ newestFromIds (NewestIds nameV versionV licenseV pairs) =
goVR (WildcardVersion v) = WildcardVersion $ getVersion v
goVR (UnionVersionRanges x y) = UnionVersionRanges (goVR x) (goVR y)
goVR (IntersectVersionRanges x y) = IntersectVersionRanges (goVR x) (goVR y)
goVR (VersionRangeParens x) = VersionRangeParens (goVR x)
goVR (MajorBoundVersion v) = MajorBoundVersion $ getVersion v
goVR (OrLaterVersion v) = OrLaterVersion $ getVersion v
goVR (OrEarlierVersion v) = OrEarlierVersion $ getVersion v
Expand Down Expand Up @@ -274,9 +271,9 @@ data PUVersionRange vr = PUVersionRange
}
deriving Generic
instance Semigroup (PUVersionRange D.VersionRange) where
PUVersionRange a x <> PUVersionRange b y = PUVersionRange (mappend a b) (D.simplifyVersionRange $ D.IntersectVersionRanges x y)
PUVersionRange a x <> PUVersionRange b y = PUVersionRange (mappend a b) (D.simplifyVersionRange $ D.intersectVersionRanges x y)
instance Monoid (PUVersionRange D.VersionRange) where
mempty = PUVersionRange mempty D.AnyVersion
mempty = PUVersionRange mempty D.anyVersion
mappend = (<>)
instance Functor PUVersionRange where
fmap f (PUVersionRange x y) = PUVersionRange x (f y)
Expand All @@ -291,7 +288,6 @@ data VersionRange version
| WildcardVersion !version -- == ver.* (same as >= ver && < ver+1)
| UnionVersionRanges !(VersionRange version) !(VersionRange version)
| IntersectVersionRanges !(VersionRange version) !(VersionRange version)
| VersionRangeParens !(VersionRange version) -- just '(exp)' parentheses syntax
| MajorBoundVersion !version -- ^>= version
| OrLaterVersion !version -- >= version
| OrEarlierVersion !version -- <= version
Expand Down Expand Up @@ -333,17 +329,16 @@ instance Show (VersionRange Version) where
show =
display . unVR
where
unVR AnyVersion = D.AnyVersion
unVR (ThisVersion v) = D.ThisVersion (unV v)
unVR (LaterVersion v) = D.LaterVersion (unV v)
unVR (EarlierVersion v) = D.EarlierVersion (unV v)
unVR (WildcardVersion v) = D.WildcardVersion (unV v)
unVR (UnionVersionRanges x y) = D.UnionVersionRanges (unVR x) (unVR y)
unVR (IntersectVersionRanges x y) = D.IntersectVersionRanges (unVR x) (unVR y)
unVR (VersionRangeParens x) = D.VersionRangeParens (unVR x)
unVR (MajorBoundVersion v) = D.MajorBoundVersion (unV v)
unVR (OrLaterVersion v) = D.OrLaterVersion (unV v)
unVR (OrEarlierVersion v) = D.OrEarlierVersion (unV v)
unVR AnyVersion = D.anyVersion
unVR (ThisVersion v) = D.thisVersion (unV v)
unVR (LaterVersion v) = D.laterVersion (unV v)
unVR (EarlierVersion v) = D.earlierVersion (unV v)
unVR (WildcardVersion v) = D.withinVersion (unV v)
unVR (UnionVersionRanges x y) = D.unionVersionRanges (unVR x) (unVR y)
unVR (IntersectVersionRanges x y) = D.intersectVersionRanges (unVR x) (unVR y)
unVR (MajorBoundVersion v) = D.majorBoundVersion (unV v)
unVR (OrLaterVersion v) = D.orLaterVersion (unV v)
unVR (OrEarlierVersion v) = D.orEarlierVersion (unV v)

unV (Version x) = x

Expand Down
24 changes: 9 additions & 15 deletions packdeps-yesod/src/Distribution/PackDeps/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Distribution.PackDeps.Util where
import ClassyPrelude.Conduit
import Distribution.PackDeps.Types
import qualified Distribution.Version as D
import qualified Distribution.Types.VersionRange.Internal as D
import qualified Prelude

withinRange :: Version -> VersionRange Version -> Bool
Expand Down Expand Up @@ -35,7 +34,6 @@ foldVersionRange anyv this later earlier union' intersect' = fold'
fold' (WildcardVersion v) = fold' (wildcard v)
fold' (UnionVersionRanges v1 v2) = union' (fold' v1) (fold' v2)
fold' (IntersectVersionRanges v1 v2) = intersect' (fold' v1) (fold' v2)
fold' (VersionRangeParens v) = fold' v
fold' (MajorBoundVersion v) = fold' (majorBound v)
fold' (OrLaterVersion v) = fold' (orLaterVersion v)
fold' (OrEarlierVersion v) = fold' (orEarlierVersion v)
Expand Down Expand Up @@ -68,20 +66,16 @@ orEarlierVersion :: Version -> VersionRange Version
orEarlierVersion v = UnionVersionRanges (ThisVersion v) (EarlierVersion v)

convertVersionRange :: D.VersionRange -> VersionRange Version
convertVersionRange =
goR
convertVersionRange = D.cataVersionRange goR
where
goR D.AnyVersion = AnyVersion
goR (D.ThisVersion x) = ThisVersion $ convertVersion x
goR (D.LaterVersion x) = LaterVersion $ convertVersion x
goR (D.EarlierVersion x) = EarlierVersion $ convertVersion x
goR (D.WildcardVersion x) = WildcardVersion $ convertVersion x
goR (D.UnionVersionRanges x y) = UnionVersionRanges (goR x) (goR y)
goR (D.IntersectVersionRanges x y) = IntersectVersionRanges (goR x) (goR y)
goR (D.VersionRangeParens x) = VersionRangeParens $ goR x
goR (D.MajorBoundVersion x) = MajorBoundVersion $ convertVersion x
goR (D.OrLaterVersion x) = OrLaterVersion $ convertVersion x
goR (D.OrEarlierVersion x) = OrEarlierVersion $ convertVersion x
goR (D.ThisVersionF x) = ThisVersion $ convertVersion x
goR (D.LaterVersionF x) = LaterVersion $ convertVersion x
goR (D.OrLaterVersionF x) = OrLaterVersion $ convertVersion x
goR (D.EarlierVersionF x) = EarlierVersion $ convertVersion x
goR (D.OrEarlierVersionF x) = OrEarlierVersion $ convertVersion x
goR (D.MajorBoundVersionF x) = MajorBoundVersion $ convertVersion x
goR (D.UnionVersionRangesF x y) = UnionVersionRanges x y
goR (D.IntersectVersionRangesF x y) = IntersectVersionRanges x y

convertVersion :: D.Version -> Version
convertVersion = Version
1 change: 0 additions & 1 deletion packdeps-yesod/src/Handler/License.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Import
import Distribution.PackDeps.Types
import Text.Lucius (luciusFile)
import qualified Data.Map as Map
import Data.Monoid ((<>))
import Data.IORef (readIORef)
import qualified Data.Set as Set

Expand Down
9 changes: 0 additions & 9 deletions packdeps-yesod/src/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ module Import
, module Data.Monoid
, module Control.Applicative
, Text
#if __GLASGOW_HASKELL__ < 704
, (<>)
#endif
, isDeep
, getDeps
, getData
Expand Down Expand Up @@ -38,12 +35,6 @@ import Distribution.PackDeps.Types (PackageName (PackageName), Version)
import Distribution.Types.PackageName (unPackageName)
import Data.IORef (readIORef)

#if __GLASGOW_HASKELL__ < 704
infixr 5 <>
(<>) :: Monoid m => m -> m -> m
(<>) = mappend
#endif

isDeep :: Handler Bool
isDeep = fmap (== Just "on") $ runInputGet $ iopt textField "deep"

Expand Down
4 changes: 4 additions & 0 deletions stack-9.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-19.33
packages:
- packdeps-cli
- packdeps-yesod
4 changes: 4 additions & 0 deletions stack-9.2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-20.26
packages:
- packdeps-cli
- packdeps-yesod
4 changes: 4 additions & 0 deletions stack-9.4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-21.25
packages:
- packdeps-cli
- packdeps-yesod
4 changes: 4 additions & 0 deletions stack-9.6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: lts-22.13
packages:
- packdeps-cli
- packdeps-yesod
4 changes: 4 additions & 0 deletions stack-9.8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resolver: nightly-2024-03-24
packages:
- packdeps-cli
- packdeps-yesod
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2020-07-24
resolver: lts-21.25
packages:
- packdeps-cli
- packdeps-yesod
Loading

0 comments on commit 3dab7c2

Please sign in to comment.