Skip to content

Commit

Permalink
Merge pull request #2 from phadej/ghc-9.2
Browse files Browse the repository at this point in the history
Use GHC-9.2, update ghc-lib-parser
  • Loading branch information
phadej committed Feb 1, 2023
2 parents 1885637 + b84cc5b commit 66ef795
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 68 deletions.
71 changes: 27 additions & 44 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.13.20211226
# version: 0.15.20230128
#
# REGENDATA ("0.13.20211226",["github","cabal.project"])
# REGENDATA ("0.15.20230128",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -23,7 +23,7 @@ on:
jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
timeout-minutes:
60
container:
Expand All @@ -32,14 +32,9 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.0.1
- compiler: ghc-9.2.5
compilerKind: ghc
compilerVersion: 9.0.1
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.10.7
compilerKind: ghc
compilerVersion: 8.10.7
compilerVersion: 9.2.5
setup-method: ghcup
allow-failure: false
fail-fast: false
Expand All @@ -48,21 +43,12 @@ jobs:
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
fi
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.9.0.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -74,20 +60,11 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.9.0.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -144,7 +121,7 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: source
- name: initial cabal.project for sdist
Expand Down Expand Up @@ -173,15 +150,15 @@ jobs:
cat >> cabal.project <<EOF
constraints: ghc-lib-parser-ex -no-ghc-lib -auto
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|hooglite)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(Cabal|hooglite|process)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: cache
uses: actions/cache@v2
- name: restore cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand All @@ -205,8 +182,14 @@ jobs:
${CABAL} -vnormal check
- name: haddock
run: |
$CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
- name: unconstrained build
run: |
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v3
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
2 changes: 1 addition & 1 deletion cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
branches: master
installed: +all -Cabal
installed: +all -Cabal -process
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
with-compiler: ghc-8.10.4
with-compiler: ghc-9.2.5
packages: .

constraints: ghc-lib-parser-ex -no-ghc-lib -auto
20 changes: 10 additions & 10 deletions hooglite.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: hooglite
version: 0.20211229
version: 0.20230131
license: BSD-3-Clause
license-file: LICENSE
category: Development
Expand All @@ -12,7 +12,7 @@ description:
author: Oleg Grenrus <oleg.grenrus@iki.fi>
maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>
build-type: Simple
tested-with: GHC ==8.10.7 || ==9.0.1
tested-with: GHC ==9.2.5
extra-source-files: test-data/*.txt

source-repository head
Expand All @@ -26,23 +26,23 @@ library

-- GHC-boot libraries
build-depends:
, base ^>=4.14.1.0 || ^>=4.15.0.0
, bytestring ^>=0.10.12.0 || ^>=0.11.1.0
, containers ^>=0.6.2.1
, base ^>=4.16.3.0
, bytestring ^>=0.11.3.1
, containers ^>=0.6.5.1
, pretty ^>=1.1.3.6

-- Cabal is special
build-depends: Cabal ^>=3.6.2.0
build-depends: Cabal ^>=3.8.1.0

-- rest of the dependencies
build-depends:
, bifunctors ^>=5.5.11
, edit-distance ^>=0.2.2.1
, fin ^>=0.2
, ghc-lib-parser ^>=9.0.1.20210324
, ghc-lib-parser-ex ^>=9.0.0.4
, fin ^>=0.2.1
, ghc-lib-parser ^>=9.4.4.20221225
, ghc-lib-parser-ex ^>=9.4.0.0
, mtl ^>=2.2.2
, text-short ^>=0.1.4
, text-short ^>=0.1.5
, unification-fd ^>=0.11.1

-- Main module
Expand Down
15 changes: 11 additions & 4 deletions src/Hooglite/Declaration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import GHC.Types.SrcLoc (GenLocated (L))
import qualified GHC.Hs.Binds as GHC
import qualified GHC.Hs.Decls as GHC
import qualified GHC.Hs.Type as GHC
import qualified GHC.Types.SrcLoc as GHC

import Hooglite.GHC.Utils
import Hooglite.MonoPoly.Name
Expand Down Expand Up @@ -58,19 +59,25 @@ sigToDeclaration :: GHC.Sig GhcPs -> (Name -> Declaration -> r) -> Either String
sigToDeclaration (GHC.TypeSig x names ty) mk = Right
[ mk (toName name) $ SigD (fmap genType $ convType ty') $ fakeShowPpr $ GHC.TypeSig x [L l name] ty
| L l name <- names
, let ty' = GHC.hsib_body $ GHC.hswc_body ty
, let ty' = GHC.sig_body $ GHC.unLoc $ GHC.hswc_body ty :: GHC.LHsType GhcPs
]
sigToDeclaration sig _ = Left $ "sigToDeclaration " ++ showAstData sig

conToDeclaration :: GHC.ConDecl GhcPs -> (Name -> Declaration -> r) -> Either String [r]
conToDeclaration d@GHC.ConDeclGADT { GHC.con_names = names, GHC.con_args = details, GHC.con_res_ty = ty } mk = Right
conToDeclaration d@GHC.ConDeclGADT { GHC.con_names = names, GHC.con_g_args = details, GHC.con_res_ty = ty } mk = Right
[ mk (toName name) $ ConD (fmap genType $ join $ apps_ <$> convType ty <*> details') (fakeShowPpr (d { GHC.con_names = [L l name] } ))
| L l name <- names
]
where
details' :: Maybe [Ty]
details' = sequence
[ convType arg
| GHC.HsScaled _ arg <- GHC.hsConDeclArgTys details
[ convType ty'
| ty' <- extractConDeclGADTDetailsTyVars details
]
conToDeclaration d@GHC.ConDeclH98 {} _mk = Left $ "Haskell98 data decl" ++ showAstData d

extractConDeclGADTDetailsTyVars ::
GHC.HsConDeclGADTDetails GhcPs -> [GHC.LHsType GhcPs]
extractConDeclGADTDetailsTyVars con_args = case con_args of
GHC.PrefixConGADT args -> map GHC.hsScaledThing args
GHC.RecConGADT (L _ flds) _ -> map (GHC.cd_fld_type . GHC.unLoc) $ flds
16 changes: 9 additions & 7 deletions src/Hooglite/GHC/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ module Hooglite.GHC.Utils where
import Data.Data (Data)
import Data.List (foldl')
import GHC.Driver.Session (DynFlags, defaultDynFlags, xopt_set)
import GHC.Parser.Lexer (ParseResult (..), getMessages)
import GHC.Utils.Error (pprErrMsgBagWithLoc)
import GHC.Utils.Outputable (Outputable, showPpr)
import GHC.Parser.Lexer (ParseResult (..), PState (errors))
import GHC.Utils.Outputable (Outputable)
import GHC.Types.Error (getMessages)
import GHC.Utils.Error (pprMsgEnvelopeBagWithLoc)
import GHC.Driver.Ppr (showPpr)

import Language.Haskell.GhclibParserEx.GHC.Settings.Config (fakeLlvmConfig, fakeSettings)

Expand All @@ -23,7 +25,7 @@ fakeShowPpr :: Outputable a => a -> String
fakeShowPpr = showPpr fakeDynFlags

showAstData :: Data a => a -> String
showAstData = fakeShowPpr . GHC.Hs.Dump.showAstData GHC.Hs.Dump.BlankSrcSpan
showAstData = fakeShowPpr . GHC.Hs.Dump.showAstData GHC.Hs.Dump.BlankSrcSpan GHC.Hs.Dump.BlankEpAnnotations

-------------------------------------------------------------------------------
-- More dynflags
Expand Down Expand Up @@ -58,6 +60,6 @@ dynFlags = foldl' xopt_set fakeDynFlags
parse :: (String -> DynFlags -> ParseResult a) -> String -> Either [String] a
parse p s = case p s dynFlags of
POk _ x -> Right x
PFailed state -> do
let (_warns, errors) = getMessages state dynFlags
Left $ map fakeShowPpr $ pprErrMsgBagWithLoc errors
PFailed pstate -> do
let es = errors pstate
Left $ map fakeShowPpr $ pprMsgEnvelopeBagWithLoc $ getMessages es
2 changes: 1 addition & 1 deletion src/Hooglite/MonoPoly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ instance Applicative (Mono n) where
(<*>) = ap

instance Monad (Mono n) where
return = Free
return = pure

Var x >>= _ = Var x
Free x >>= k = k x
Expand Down

0 comments on commit 66ef795

Please sign in to comment.