Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ jobs:
# versions of our dependencies allowed by our upper bounds.
#
# TODO: switch back to "ghc: latest" once we support ghc-9.0
- name: newest
- name: oldest
ghc: "8.10"
os: ubuntu-latest
- name: newest
ghc: "9.0"
os: ubuntu-latest

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -118,7 +121,7 @@ jobs:
strategy:
matrix:
include:
- ghc: "8.10"
- ghc: "9.0"
os: ubuntu-latest

steps:
Expand Down
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ dependencies:
library:
source-dirs: src
dependencies:
- ghc >= 8.10.2 && < 9.0
- ghc >= 8.10.2 && <9.1
- containers >= 0.6.2.1
- term-rewriting >= 0.3.0.1
- transformers >= 0.5.6.2
default-extensions: CPP

tests:
should-compile:
Expand Down
12 changes: 12 additions & 0 deletions src/TypeLevel/Rewrite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import Data.Foldable
import Data.Traversable

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Core.Coercion (Role(Representational), mkUnivCo)
import GHC.Tc.Types.Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical)
import GHC.Plugins (PredType, SDoc, eqType, fsep, ppr)
import GHC.Plugins (Plugin(pluginRecompile, tcPlugin), CommandLineOption, defaultPlugin, purePlugin)
import GHC.Tc.Types.Evidence (EvExpr, EvTerm, evCast)
import GHC.Tc.Plugin (newWanted)
import GHC.Core.TyCo.Rep (UnivCoProvenance(PluginProv))
import GHC.Plugins (synTyConDefn_maybe)
import GHC.Tc.Types (TcPluginResult(..), TcPluginM, ErrCtxt, pushErrCtxtSameOrigin, TcPlugin(..))
#else
import Coercion (Role(Representational), mkUnivCo)
import Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical)
import GhcPlugins (PredType, SDoc, eqType, fsep, ppr)
Expand All @@ -17,6 +28,7 @@ import TcPluginM (newWanted)
import TcRnTypes
import TyCoRep (UnivCoProvenance(PluginProv))
import TyCon (synTyConDefn_maybe)
#endif

import TypeLevel.Rewrite.Internal.ApplyRules
import TypeLevel.Rewrite.Internal.DecomposedConstraint
Expand Down
4 changes: 4 additions & 0 deletions src/TypeLevel/Rewrite/Internal/ApplyRules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import Data.Traversable
import qualified Data.Map as Map

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Plugins (TyVar)
#else
import Type (TyVar)
#endif

-- term-rewriting API
import Data.Rewriting.Rule (Rule(..))
Expand Down
5 changes: 5 additions & 0 deletions src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import Control.Applicative

-- GHC API
import GHC (Class, Type)
#if MIN_VERSION_ghc(9,0,0)
import GHC.Tc.Types.Constraint (Ct, ctEvPred, ctEvidence)
import GHC.Core.Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred)
#else
import Constraint (Ct, ctEvPred, ctEvidence)
import Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred)
#endif


data DecomposedConstraint a
Expand Down
18 changes: 13 additions & 5 deletions src/TypeLevel/Rewrite/Internal/Lookup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ import Control.Arrow ((***), first)
import Data.Tuple (swap)

-- GHC API
import Finder (cannotFindModule)
import GHC (DataCon, TyCon, dataConTyCon)
#if MIN_VERSION_ghc(9,0,0)
import GHC.Driver.Finder (cannotFindModule)
import GHC (Module, ModuleName, mkModuleName)
import GHC.Plugins (mkDataOcc, mkTcOcc)
import GHC.Utils.Panic (panicDoc)
import GHC.Tc.Plugin
( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon
, unsafeTcPluginTcM
)
import GHC.Tc.Solver.Monad (getDynFlags)
#else
import Finder (cannotFindModule)
import Module (Module, ModuleName, mkModuleName)
import OccName (mkDataOcc, mkTcOcc)
import Panic (panicDoc)
import TcPluginM
( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon
, unsafeTcPluginTcM
)
import TcSMonad (getDynFlags)

#endif

lookupModule
:: String -- ^ module name
Expand Down
6 changes: 6 additions & 0 deletions src/TypeLevel/Rewrite/Internal/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ module TypeLevel.Rewrite.Internal.PrettyPrint where
import Data.List (intercalate)

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Utils.Outputable (ppr, showSDocUnsafe)
import GHC.Plugins (TyCon)
import GHC.Plugins (TyVar, Type)
#else
import Outputable (ppr, showSDocUnsafe)
import TyCon (TyCon)
import Type (TyVar, Type)
#endif

-- term-rewriting API
import Data.Rewriting.Rule (Rule(..))
Expand Down
4 changes: 4 additions & 0 deletions src/TypeLevel/Rewrite/Internal/TypeEq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module TypeLevel.Rewrite.Internal.TypeEq where

import Data.Function

#if MIN_VERSION_ghc(9,0,0)
import GHC.Plugins (Type, eqType)
#else
import GhcPlugins (Type, eqType)
#endif


-- | A newtype around 'Type' which has an 'Eq' instance.
Expand Down
5 changes: 5 additions & 0 deletions src/TypeLevel/Rewrite/Internal/TypeNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
module TypeLevel.Rewrite.Internal.TypeNode where

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC (TyCon)
import GHC.Plugins (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe)
#else
import TyCon (TyCon)
import Type (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe)
#endif

import TypeLevel.Rewrite.Internal.TypeEq

Expand Down
6 changes: 6 additions & 0 deletions src/TypeLevel/Rewrite/Internal/TypeRule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
module TypeLevel.Rewrite.Internal.TypeRule where

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Plugins (getOccString)
import GHC.Core.Predicate (mkPrimEqPred)
import GHC.Plugins (TyVar, Type, mkTyVarTy)
#else
import Name (getOccString)
import Predicate (mkPrimEqPred)
import Type (TyVar, Type, mkTyVarTy)
#endif

-- term-rewriting API
import Data.Rewriting.Rule (Rule(..))
Expand Down
4 changes: 4 additions & 0 deletions src/TypeLevel/Rewrite/Internal/TypeTemplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
module TypeLevel.Rewrite.Internal.TypeTemplate where

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Plugins (TyVar, Type, getTyVar_maybe)
#else
import Type (TyVar, Type, getTyVar_maybe)
#endif

-- term-rewriting API
import Data.Rewriting.Term (Term(Fun, Var))
Expand Down
4 changes: 4 additions & 0 deletions src/TypeLevel/Rewrite/Internal/TypeTerm.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
module TypeLevel.Rewrite.Internal.TypeTerm where

-- GHC API
#if MIN_VERSION_ghc(9,0,0)
import GHC.Plugins (Type, mkTyConApp)
#else
import Type (Type, mkTyConApp)
#endif

-- term-rewriting API
import Data.Rewriting.Term (Term(Fun, Var))
Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resolver: nightly-2020-12-10
resolver: nightly-2021-07-22
packages:
- '.'

extra-deps:
- term-rewriting-0.4.0.2
- union-find-array-0.1.0.2
- union-find-array-0.1.0.3
27 changes: 26 additions & 1 deletion test/error-messages-cases/no-plugin/expected
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
• Couldn't match type ‘as ++ (bs ++ cs)’ with ‘(as ++ bs) ++ cs’
configure (lib)
Configuring no-plugin-0.0.0...
build (lib)
Preprocessing library for no-plugin-0.0.0..
Building library for no-plugin-0.0.0..
[1 of 2] Compiling NoPlugin.Test

<path>/error-messages-cases/no-plugin/src/NoPlugin/Test.hs:15:16: error:
• Couldn't match type: as ++ (bs ++ cs)
with: (as ++ bs) ++ cs
Expected: proxy ((as ++ bs) ++ cs)
Actual: proxy (as ++ (bs ++ cs))
NB: ‘++’ is a non-injective type family
• In the expression: r
In an equation for ‘ex2e’: ex2e _ _ _ r = r
• Relevant bindings include
r :: proxy (as ++ (bs ++ cs)) (bound at src/NoPlugin/Test.hs:15:12)
ex2e :: proxy as
-> proxy bs
-> proxy cs
-> proxy (as ++ (bs ++ cs))
-> proxy ((as ++ bs) ++ cs)
(bound at src/NoPlugin/Test.hs:15:1)
|
15 | ex2e _ _ _ r = r
| ^
2 changes: 1 addition & 1 deletion test/should-compile/GHC/TypeLits/Test.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators #-}
{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators, AllowAmbiguousTypes #-}
{-# OPTIONS_GHC -fplugin TypeLevel.Rewrite
-fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.NatRule
-fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.SymbolRule #-}
Expand Down
8 changes: 5 additions & 3 deletions typelevel-rewrite-rules.cabal
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.33.0.
-- This file has been generated from package.yaml by hpack version 0.34.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: 2673197ba6a9e92128e851017519e221b95a23ca70b1f7b84158feae74eba11b
-- hash: 201dd297be3e249f9d5773e714652b18086e8f3160a1bdca783242cb52598513

name: typelevel-rewrite-rules
version: 1.0
Expand Down Expand Up @@ -48,11 +48,13 @@ library
build-depends:
base >=4.12 && <5
, containers >=0.6.2.1
, ghc >=8.10.2 && <9.0
, ghc >=8.10.2 && <9.1
, ghc-prim >=0.5.3
, term-rewriting >=0.3.0.1
, transformers >=0.5.6.2
default-language: Haskell2010
default-extensions:
CPP

test-suite should-compile
type: exitcode-stdio-1.0
Expand Down