Skip to content

Commit

Permalink
Support ghc 9.4 and 9.6 (#18)
Browse files Browse the repository at this point in the history
* support ghc 9.4 and 9.6

* exclude some toolchains from CI

* fix hoogle generation for ghc bundled libraries

* run CI on more toolchains

* always try the replacement
  • Loading branch information
kokobd authored Feb 25, 2024
1 parent 7452c2b commit 3cfa5fd
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 32 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ jobs:
- ubuntu-latest
- macos-latest
ghc:
- "8.10.7"
- "9.0.2"
- "9.2.4"
exclude:
# precompiled 9.0 and 9.2 don't have docs
- os: macos-latest
ghc: "9.0.2"
- os: macos-latest
ghc: "9.2.4"
- "9.2.8"
- "9.4.8"
- "9.6.4"
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -31,18 +25,13 @@ jobs:
ghcup list
ghcup rm ghc ${{ matrix.ghc }} || true
ghcup install ghc ${{ matrix.ghc }} --set
ghcup install cabal 3.6.2.0 --set
ghcup install cabal 3.10.2.1 --set
cabal update
- name: Build
run: |
cabal build all --enable-tests
- name: Run Tests
run: cabal test --test-show-details=always all
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
post_job:
runs-on: ubuntu-latest
needs: [test]
Expand Down
4 changes: 2 additions & 2 deletions cabal-hoogle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ library
, optparse-applicative >=0.16 && <1
, regex-tdfa ^>=1.3.1
, string-interpolate ^>=0.3.1.2
, text ^>=1.2.4
, text ^>=1.2.4 || ^>=2.0
, time >=1.10 && <2
, transformers ^>=0.5.6
, transformers ^>=0.5.6 || ^>=0.6
, typed-process ^>=0.2.10

default-language: Haskell2010
Expand Down
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
packages: ./
index-state: 2023-06-05T00:00:00Z
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
compilers = [ "ghc8107" "ghc926" "ghc944" ];
defaultCompiler = "ghc8107";
compilers = [ "ghc92" "ghc94" "ghc96" ];
defaultCompiler = "ghc94";

mkShell = compiler: pkgs.mkShell {
buildInputs = with pkgs; [
Expand All @@ -20,10 +20,10 @@
haskell.compiler.${compiler}
ormolu
miniserve
] ++ (with haskell.packages.${compiler}; [
haskell-language-server
cabal-fmt
]);
] ++ (with haskell.packages.${compiler};
(lib.lists.optional (compiler != "ghc96") haskell-language-server) ++
[ cabal-fmt ghcid ]
);
shellHook = ''
export CABAL_DIR=$(pwd)/.cabal
export CABAL_CONFIG=$(pwd)/.cabal/config
Expand Down
17 changes: 15 additions & 2 deletions src/Hoogle/Cabal/Command/Generate.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
Expand All @@ -21,6 +22,7 @@ import qualified Data.List.NonEmpty.Extra as NonEmpty
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes)
import Data.String.Interpolate (i)
import qualified Data.Text as T
import Data.Traversable (forM)
import Distribution.Client.CmdBuild
( buildAction,
Expand All @@ -33,7 +35,7 @@ import Distribution.Client.ProjectOrchestration
)
import Distribution.Client.ProjectPlanning (ElaboratedConfiguredPackage)
import Distribution.Client.ProjectPlanning.Types (elabDistDirParams)
import Distribution.InstalledPackageInfo (InstalledPackageInfo (haddockHTMLs, installedUnitId))
import Distribution.InstalledPackageInfo (InstalledPackageInfo (haddockHTMLs, installedUnitId, pkgRoot))
import Distribution.Simple (UnitId)
import Distribution.Simple.Configure (ConfigStateFileError, tryGetPersistBuildConfig)
import Distribution.Simple.PackageIndex (allPackagesByName)
Expand Down Expand Up @@ -150,7 +152,7 @@ symlinkDependencies logger localPackages hoogleDependenciesDir = do
unless (null pkgs) $
logWith logger Warning $
LogPkgMoreThan1Version name (fmap installedUnitId allPkgs)
case haddockHTMLs pkg of
case haddockHTMLs' pkg of
[htmlDir] -> pure $ Just (name, htmlDir)
htmlDirs -> do
logWith logger Warning $ LogPkgBadHaddockHtml name htmlDirs
Expand All @@ -159,8 +161,19 @@ symlinkDependencies logger localPackages hoogleDependenciesDir = do
createDirectoryLink dir (hoogleDependenciesDir </> PackageName.unPackageName name)
pure name
where
collectDependenciesForPkg :: LocalBuildInfo -> [(PackageName, NonEmpty InstalledPackageInfo)]
collectDependenciesForPkg pkg =
let depsWithName = allPackagesByName (LocalBuildInfo.installedPkgs pkg)
in fmap (second (NonEmpty.:| []))
. concatMap (\(name, pkgs) -> fmap (name,) pkgs)
$ depsWithName

haddockHTMLs' :: InstalledPackageInfo -> [FilePath]
haddockHTMLs' pkg =
fmap
( case pkgRoot pkg of
Nothing -> id
Just pkgRoot' -> T.unpack . T.replace "${pkgroot}" (T.pack pkgRoot') . T.pack
)
. haddockHTMLs
$ pkg

0 comments on commit 3cfa5fd

Please sign in to comment.