Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GHC 9. #2

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: concat
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
ghc:
# - "8.0.2" # We've (temporarily?) lost support for these, but still
# - "8.2.2" # have conditional compilation for them. We should either
# - "8.4.1" # fix (some) of them or remove the CPP.
- "8.6.1"
- "8.8.1"
- "8.10.1"
- "9.0.1"
- "9.2.1"
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: "3.6.0.0"
- run: cabal v2-update
- run: cabal v2-freeze $CONFIG
- uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
- run: cabal new-build all
- run: cabal new-test gold-tests
5 changes: 0 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ source-repository-package
tag: master
subdir: verilog

source-repository-package
type: git
location: https://github.com/expipiplus1/vector-sized.git
tag: master

packages:
./inline/concat-inline.cabal
./plugin/concat-plugin.cabal
Expand Down
4 changes: 2 additions & 2 deletions classes/src/ConCat/Category.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ class BottomCat k a b where
-- bottomC = bottomC &&& bottomC

instance (BottomCat k a b, ClosedCat k, Ok4 k z b a (z -> b)) => BottomCat k a (z -> b) where
bottomC = curry (bottomC . exl) <+ okProd @k @a @ z
bottomC = curry (bottomC . exl) <+ okProd @k @a @z

instance BottomCat (->) a b where bottomC = error "bottomC for (->) evaluated"

Expand Down Expand Up @@ -2075,7 +2075,7 @@ class ({- Pointed h, -} OkFunctor k h, Ok k a) => PointedCat k h a where
-- class (Ok k a, Num a) => SumCat k h a where
-- sumC :: h a `k` a

class (Ok k a, Additive a) => AddCat k h a where
class Ok k a => AddCat k h a where
sumAC :: h a `k` a

-- class IxSummable n => IxSummableCat k n where
Expand Down
120 changes: 0 additions & 120 deletions examples/concat-examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ library
, concat-inline
, concat-known
, concat-classes
, concat-plugin
if flag(smt)
build-depends: z3
cpp-options: -DCONCAT_SMT
Expand Down Expand Up @@ -114,70 +113,6 @@ library
ghc-options: -O2
cpp-options: -DVectorSized

-- Stack apparently only allows per-package flags, not per-component, so the
-- whole library gets recompiled. For now, duplicate the test-suite. See
-- <https://stackoverflow.com/questions/45015821/setting-component-specific-cabal-flag-from-stack-build>

Test-Suite misc-examples
type: exitcode-stdio-1.0
default-language: Haskell98
hs-Source-Dirs: test
main-is: Examples.hs
other-modules: Miscellany
Build-Depends: base<5
, Cabal >= 1.24.0.0
, ghc-prim
, constraints >= 0.8
, newtype-generics >= 0.5.3
, pointed, keys
, distributive, adjunctions
, concat-inline
, concat-classes
, concat-plugin
, concat-examples
, ghc-prim
, integer-gmp
, distributive, adjunctions
, constraints >= 0.8
-- Array/vector experiments
, finite-typelits, vector-sized >= 1.0.0.0
ghc-options: -O2
-fplugin=ConCat.Plugin
if flag(smt)
cpp-options: -DCONCAT_SMT
cpp-options: -DVectorSized

Test-Suite misc-trace
type: exitcode-stdio-1.0
default-language: Haskell98
hs-Source-Dirs: test
main-is: Examples.hs
other-modules: Miscellany
Build-Depends: base<5
, Cabal >= 1.24.0.0
, ghc-prim
, constraints >= 0.8
, newtype-generics >= 0.5.3
, pointed, keys
, distributive, adjunctions
, concat-inline
, concat-classes
, concat-plugin
, concat-examples
, ghc-prim
, integer-gmp
, keys
, distributive, adjunctions
, constraints >= 0.8
-- Array/vector experiments
, finite-typelits, vector-sized
ghc-options: -O2
-fplugin=ConCat.Plugin
-fplugin-opt=ConCat.Plugin:trace
if flag(smt)
cpp-options: -DCONCAT_SMT
cpp-options: -DVectorSized

-- Test-Suite testHasFins
-- type: exitcode-stdio-1.0
-- default-language: Haskell98
Expand All @@ -189,58 +124,3 @@ Test-Suite misc-trace
-- , concat-examples
-- , concat-classes
-- , ghc-typelits-knownnat

Test-Suite gold-tests
type: exitcode-stdio-1.0
default-language: Haskell98
hs-Source-Dirs: test
main-is: GoldTests.hs
other-modules: BasicTests, Miscellany, Utils
Build-Depends: base<5
, Cabal >= 1.24.0.0
, ghc-prim
, constraints >= 0.8
, newtype-generics >= 0.5.3
, pointed, keys
, distributive, adjunctions
, vector
, concat-inline
, concat-classes
, concat-plugin
, concat-examples
, ghc-prim
, integer-gmp
, distributive, adjunctions
, constraints >= 0.8
, bytestring
, tasty
, tasty-golden
-- Array/vector experiments
, finite-typelits, vector-sized >= 1.0.0.0
ghc-options: -O2
-fplugin=ConCat.Plugin
-- -fplugin-opt=ConCat.Plugin:showCcc
-- -dppr-debug -dverbose-core2core -dinline-check satisfy -ddump-inlinings
if flag(smt)
cpp-options: -DCONCAT_SMT
cpp-options: -DVectorSized

-- executable ad_rev
-- hs-source-dirs: app
-- main-is: ad_rev.lhs
-- build-depends: base >= 4.7 && < 5
-- , optparse-generic
-- , concat-classes
-- , concat-examples
-- , concat-plugin
-- default-language: Haskell2010
-- ghc-options: -O2
-- -funbox-strict-fields
-- -threaded
-- -optc-ffast-math
-- -optc-O3
-- -- -fplugin=ConCat.Plugin
-- -- -fplugin-opt=ConCat.Plugin:trace
-- -- -fplugin-opt=ConCat.Plugin:maxSteps=200
-- -- -fforce-recomp

3 changes: 2 additions & 1 deletion examples/src/ConCat/Dual.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TupleSections #-}
Expand Down Expand Up @@ -224,7 +225,7 @@ instance (PointedCat k h a, Additive a) => AddCat (Dual k) h a where
sumAC = abst pointC
{-# INLINE sumAC #-}

instance (AddCat k h a, OkF k h) => PointedCat (Dual k) h a where
instance (AddCat k h a, Additive a, OkF k h) => PointedCat (Dual k) h a where
pointC = abst sumAC
{-# INLINE pointC #-}

Expand Down
8 changes: 4 additions & 4 deletions examples/src/ConCat/StackVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ evalStackFun (SF f) = rcounit . f . runit

instance Category StackFun where
id = stackFun id
-- SF g . SF f = SF (g . f)
(.) = inSF2 (.)
SF g . SF f = SF (g . f)
-- (.) = inSF2 (.)
{-# INLINE id #-}
{-# INLINE (.) #-}

Expand All @@ -70,9 +70,9 @@ instance AssociativePCat StackFun where
{-# INLINE rassocP #-}

instance MonoidalPCat StackFun where
first = inSF inRassocP -- okay
-- first = inSF inRassocP -- okay
-- first (SF f) = SF (inRassocP f)
-- first (SF f) = SF (lassocP . f . rassocP)
first (SF f) = SF (lassocP . f . rassocP)
-- first (SF f) = SF lassocP . SF f . SF rassocP -- doesn't type-check
second = secondFirst
f *** g = second g . first f
Expand Down
2 changes: 2 additions & 0 deletions examples/src/ConCat/TArr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ import Prelude hiding (id, (.), const, curry, uncurry) -- Coming from ConCat.Al
import Data.Monoid
import Data.Foldable
import GHC.TypeLits
#if !MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
import GHC.Types (Nat)
#endif
import GHC.Generics (U1(..),Par1(..),(:*:)(..),(:.:)(..))
import GHC.Exts (Coercible,coerce)

Expand Down
18 changes: 17 additions & 1 deletion inline/src/ConCat/Inline/Plugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ import qualified ConCat.Inline.ClassOp as CO
import Data.List (elemIndex)

-- GHC API
#if MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
import qualified GHC.Driver.Backend as Backend
import GHC.Types.TyThing (lookupId, lookupTyCon)
#endif
#if MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
import GHC.Core.Class (classAllSelIds)
import GHC.Plugins
import GHC.Types.Id.Make (mkDictSelRhs)
import GHC.Runtime.Loader
#else
import GhcPlugins
import Class (classAllSelIds)
import MkId (mkDictSelRhs)
import DynamicLoading
#endif

plugin :: Plugin
plugin = defaultPlugin { installCoreToDos = install
Expand All @@ -29,9 +40,14 @@ install _opts todos =
do dflags <- getDynFlags
-- Unfortunately, the plugin doesn't work in GHCi. Until fixed,
-- disable under GHCi, so we can at least type-check conveniently.
#if MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
if backend dflags == Backend.Interpreter then
return todos
#else
if hscTarget dflags == HscInterpreted then
return todos
else
#endif
else
do
#if !MIN_VERSION_GLASGOW_HASKELL(8,2,0,0)
reinitializeGlobals
Expand Down
Loading