diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8393352..6128a42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,11 @@ jobs: - "9.0.2" - "9.2.8" - "9.4.8" - - "9.6.4" - - "9.8.2" - - "9.10.1" + - "9.6.7" + - "9.8.4" + - "9.10.3" + - "9.12.4" + - "9.14.1" steps: - uses: actions/checkout@v3 diff --git a/cabal.project b/cabal.project index b764c34..eb4d5bc 100644 --- a/cabal.project +++ b/cabal.project @@ -1,2 +1,12 @@ packages: . +-- GHC 9.14 pulls in newer compiler-bundled libraries than some transitive +-- Hackage bounds currently allow, but this specific package set builds +-- successfully. +allow-newer: + these:base, + indexed-traversable-instances:base, + indexed-traversable:base, + indexed-traversable:containers, + string-interpolate:template-haskell, + boring:base diff --git a/circuit-notation.cabal b/circuit-notation.cabal index 41972c0..42d8f52 100644 --- a/circuit-notation.cabal +++ b/circuit-notation.cabal @@ -29,7 +29,7 @@ library , clash-prelude >= 1.0 , containers , data-default - , ghc (>=8.6 && <8.8) || (>=8.10 && < 9.12) + , ghc (>=8.6 && <8.8) || (>=8.10 && < 9.15) , lens , mtl , parsec diff --git a/flake.lock b/flake.lock index 05c26e1..d143546 100644 --- a/flake.lock +++ b/flake.lock @@ -4,18 +4,18 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "ghc-tcplugins-extra": "ghc-tcplugins-extra", + "ghc-tcplugin-api": "ghc-tcplugin-api", "ghc-typelits-extra": "ghc-typelits-extra", "ghc-typelits-knownnat": "ghc-typelits-knownnat", "ghc-typelits-natnormalise": "ghc-typelits-natnormalise", "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1754301255, - "narHash": "sha256-dne2oWxOEosMYumUZZhc3c8NyJMdiqpb/xvd1saTp30=", + "lastModified": 1775805247, + "narHash": "sha256-H2Enis6kJiM09odRPBdnveWbDJjA8pecBD8cldho0oE=", "owner": "clash-lang", "repo": "clash-compiler", - "rev": "6a0810496560e2ff2a0071f315afb573c12bba39", + "rev": "6882ebed5ec34ec64de44c846bc0a77b33fb5f4f", "type": "github" }, "original": { @@ -27,11 +27,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { @@ -45,11 +45,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -75,30 +75,30 @@ "type": "indirect" } }, - "ghc-tcplugins-extra": { + "ghc-tcplugin-api": { "flake": false, "locked": { - "lastModified": 1716385093, - "narHash": "sha256-pXQoPP22TicWFwpWub9CX1J+rpOKfyX2IyzlCg1qG84=", - "owner": "clash-lang", - "repo": "ghc-tcplugins-extra", - "rev": "702dda2095c66c4f5148a749c8b7dbcc8a09f5c1", + "lastModified": 1768388673, + "narHash": "sha256-3RriTela4iwbvHhF3UigmBOfxJv0+YQGAlXQbnXsX74=", + "owner": "sheaf", + "repo": "ghc-tcplugin-api", + "rev": "c583750b5899846cb455f3fe2d58b3ba9bc910d0", "type": "github" }, "original": { - "owner": "clash-lang", - "repo": "ghc-tcplugins-extra", + "owner": "sheaf", + "repo": "ghc-tcplugin-api", "type": "github" } }, "ghc-typelits-extra": { "flake": false, "locked": { - "lastModified": 1716411282, - "narHash": "sha256-YH03Ce+TEWKHGAm7BhynitZomfpYeKpqvZAviw8yEPA=", + "lastModified": 1773994244, + "narHash": "sha256-BPOTj6Dqv2Nt+C47MCayXzItXRf3HC4f2kV7lnAjAEY=", "owner": "clash-lang", "repo": "ghc-typelits-extra", - "rev": "4dadc824a3ef9a511fcf6605167715a5a655ba0d", + "rev": "1d38c49f456406937c5e9e3b3e382af6ccbff0e1", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "ghc-typelits-knownnat": { "flake": false, "locked": { - "lastModified": 1716408841, - "narHash": "sha256-A2v6GkMtSJqZXpTwWfIcwshieyRySeR1bP+NogUHNoo=", + "lastModified": 1774000279, + "narHash": "sha256-41mjxMsWHXmAS2bxYVsE3OOav3sWnwPbpP56aRDVUNU=", "owner": "clash-lang", "repo": "ghc-typelits-knownnat", - "rev": "2e57de3b709dab085fb1657cf73d4f5e833229ee", + "rev": "21fb8294266484b2e267f3850f5437e87d8b241f", "type": "github" }, "original": { @@ -126,11 +126,11 @@ "ghc-typelits-natnormalise": { "flake": false, "locked": { - "lastModified": 1716387676, - "narHash": "sha256-G5p0NUy4CpjxGO1VNhb38fhkXESFPxGaZJM0qd6L74U=", + "lastModified": 1773940027, + "narHash": "sha256-MGdoDIOWAHk9IERWtGQhxB5AlBAVbmtCUouKJUv122g=", "owner": "clash-lang", "repo": "ghc-typelits-natnormalise", - "rev": "84f500a9735675e96253181939c3473a567f6f7a", + "rev": "5adf333887f5f9f00e47f69368a2b5e9705c9cbc", "type": "github" }, "original": { @@ -141,11 +141,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727089097, - "narHash": "sha256-ZMHMThPsthhUREwDebXw7GX45bJnBCVbfnH1g5iuSPc=", + "lastModified": 1775639890, + "narHash": "sha256-9O9gNidrdzcb7vgKGtff7QiLtr0IsVaCi0pAXm8anhQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "568bfef547c14ca438c56a0bece08b8bb2b71a9c", + "rev": "456e8a9468b9d46bd8c9524425026c00745bc4d2", "type": "github" }, "original": { diff --git a/src/CircuitNotation.hs b/src/CircuitNotation.hs index 62104fe..ca3b886 100644 --- a/src/CircuitNotation.hs +++ b/src/CircuitNotation.hs @@ -43,6 +43,9 @@ module CircuitNotation import Control.Exception import qualified Data.Data as Data import Data.Default +#if __GLASGOW_HASKELL__ >= 914 +import Data.List.NonEmpty (NonEmpty((:|))) +#endif import Data.Maybe (fromMaybe) #if __GLASGOW_HASKELL__ >= 900 #else @@ -72,10 +75,6 @@ import HscTypes (throwOneError) import qualified GHC.Parser.Annotation as GHC #endif -#if __GLASGOW_HASKELL__ >= 910 -import GHC.Hs (EpAnn) -#endif - #if __GLASGOW_HASKELL__ >= 900 import GHC.Data.Bag import GHC.Data.FastString (mkFastString, unpackFS) @@ -107,7 +106,11 @@ import GHC.Driver.Errors.Ppr () -- instance Diagnostic GhcMessage import qualified GHC.Driver.Config.Diagnostic as GHC import qualified GHC.Driver.Errors.Types as GHC import qualified GHC.Utils.Logger as GHC +#if __GLASGOW_HASKELL__ < 910 import qualified GHC.Parser.PostProcess as GHC +#else +import GHC.Parser.PostProcess () -- instances +#endif #endif #if __GLASGOW_HASKELL__ > 808 @@ -245,9 +248,6 @@ sevFatal = Err.MCFatal #if __GLASGOW_HASKELL__ >= 910 noExt :: NoAnn a => a noExt = noAnn - -instance NoAnn NoExtField where - noAnn = noExtField #elif __GLASGOW_HASKELL__ > 900 noExt :: EpAnn ann noExt = EpAnnNotUsed @@ -532,7 +532,13 @@ appTy :: LHsType GhcPs -> LHsType GhcPs -> LHsType GhcPs appTy a b = noLoc (HsAppTy noExtField a (parenthesizeHsType GHC.appPrec b)) appE :: LHsExpr GhcPs -> LHsExpr GhcPs -> LHsExpr GhcPs -appE fun arg = L noSrcSpanA $ HsApp noExt fun (parenthesizeHsExpr GHC.appPrec arg) +appE fun arg = L noSrcSpanA $ HsApp +#if __GLASGOW_HASKELL__ >= 910 + noExtField +#else + noAnn +#endif + fun (parenthesizeHsExpr GHC.appPrec arg) varE :: SrcSpanAnnA -> GHC.RdrName -> LHsExpr GhcPs varE loc rdr = L loc (HsVar noExtField (noLoc rdr)) @@ -566,7 +572,13 @@ vecE srcLoc = \case [] -> go srcLoc [] as -> parenE $ go srcLoc as where - go loc (e@(L l _):es) = L loc $ OpApp noExt e (varE l (thName '(:>))) (go loc es) + go loc (e@(L l _):es) = L loc $ OpApp +#if __GLASGOW_HASKELL__ >= 912 + noExtField +#else + noExt +#endif + e (varE l (thName '(:>))) (go loc es) go loc [] = varE loc (thName 'Nil) tupE :: p ~ GhcPs => SrcSpanAnnA -> [LHsExpr p] -> LHsExpr p @@ -574,7 +586,13 @@ tupE _ [ele] = ele tupE loc elems = L loc $ ExplicitTuple noExt tupArgs GHC.Boxed where #if __GLASGOW_HASKELL__ >= 902 - tupArgs = map (Present noExt) elems + tupArgs = map +#if __GLASGOW_HASKELL__ >= 910 + (Present noExtField) +#else + (Present noAnn) +#endif + elems #else tupArgs = map (\arg@(L l _) -> L l (Present noExt arg)) elems #endif @@ -585,7 +603,11 @@ unL (L _ a) = a -- | Get a ghc name from a TH name that's known to be unique. thName :: TH.Name -> GHC.RdrName thName nm = +#if __GLASGOW_HASKELL__ >= 914 + case Convert.thRdrNameGuesses False nm of +#else case Convert.thRdrNameGuesses nm of +#endif [name] -> name _ -> error "thName called on a non NameG Name" @@ -612,9 +634,17 @@ simpleLambda expr = do #else HsLam _ _ (MG _x alts) <- Just expr #endif +#if __GLASGOW_HASKELL__ >= 912 + L _ [L _ (Match _matchX _matchContext (L _ matchPats) matchGr)] <- Just alts +#else L _ [L _ (Match _matchX _matchContext matchPats matchGr)] <- Just alts +#endif GRHSs _grX grHss _grLocalBinds <- Just matchGr +#if __GLASGOW_HASKELL__ >= 914 + L _ (GRHS _ _ body) :| [] <- Just grHss +#else [L _ (GRHS _ _ body)] <- Just grHss +#endif Just (matchPats, body) -- | Create a simple let binding. @@ -660,7 +690,11 @@ letE loc sigs binds expr = valBinds = ValBinds noAnnSortKey hsBinds sigs hsBinds :: LHsBindsLR GhcPs GhcPs +#if __GLASGOW_HASKELL__ >= 912 + hsBinds = binds +#else hsBinds = listToBag binds +#endif -- | Simple construction of a lambda expression lamE :: [LPat GhcPs] -> LHsExpr GhcPs -> LHsExpr GhcPs @@ -682,18 +716,31 @@ lamE pats expr = mg = MG (GHC.Generated GHC.OtherExpansion GHC.DoPmc) matches #endif +#if __GLASGOW_HASKELL__ >= 912 + matches :: XRec GhcPs [LMatch GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))] + matches = noLoc [singleMatch] +#else matches :: GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))] matches = noLoc $ [singleMatch] +#endif singleMatch :: GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))) -#if __GLASGOW_HASKELL__ >= 910 +#if __GLASGOW_HASKELL__ >= 912 + singleMatch = noLoc $ Match noExtField (LamAlt LamSingle) (L (EpaSpan noSrcSpan) pats) grHss +#elif __GLASGOW_HASKELL__ >= 910 singleMatch = noLoc $ Match noExt (LamAlt LamSingle) pats grHss #else singleMatch = noLoc $ Match noExt LambdaExpr pats grHss #endif grHss :: GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) - grHss = GRHSs emptyComments [grHs] $ + grHss = GRHSs emptyComments +#if __GLASGOW_HASKELL__ >= 914 + (grHs :| []) +#else + [grHs] +#endif + $ #if __GLASGOW_HASKELL__ >= 902 (EmptyLocalBinds noExtField) #else @@ -790,7 +837,11 @@ handleStmtM (L loc stmt) = case stmt of -- a regular let bindings case letBind of HsValBinds _ (ValBinds _ valBinds sigs) -> do +#if __GLASGOW_HASKELL__ >= 912 + circuitLets <>= valBinds +#else circuitLets <>= bagToList valBinds +#endif circuitTypes <>= sigs _ -> errM (locA loc) ("Unhandled let statement" <> show (Data.toConstr letBind)) BodyStmt _xbody body _idr _idr' -> @@ -809,7 +860,9 @@ bindSlave (L loc expr) = case expr of VarPat _ (L _ rdrName) -> Ref (PortName loc (fromRdrName rdrName)) TuplePat _ lpat _ -> Tuple $ fmap bindSlave lpat ParPatP lpat -> bindSlave lpat -#if __GLASGOW_HASKELL__ >= 902 +#if __GLASGOW_HASKELL__ >= 914 + ConPat _ (L _ (GHC.Unqual occ)) (PrefixCon [lpat]) +#elif __GLASGOW_HASKELL__ >= 902 ConPat _ (L _ (GHC.Unqual occ)) (PrefixCon [] [lpat]) #elif __GLASGOW_HASKELL__ >= 900 ConPat _ (L _ (GHC.Unqual occ)) (PrefixCon [lpat]) @@ -1035,7 +1088,13 @@ createInputs -> PortDescription PortName -- ^ master ports -> LHsExpr p -createInputs dir slaves masters = noLoc $ OpApp noExt s2m (varE noSrcSpanA (fwdBwdCon ?nms)) m2s +createInputs dir slaves masters = noLoc $ OpApp +#if __GLASGOW_HASKELL__ >= 912 + noExtField +#else + noExt +#endif + s2m (varE noSrcSpanA (fwdBwdCon ?nms)) m2s where m2s = expWithSuffix (revDirec dir) masters s2m = expWithSuffix dir slaves @@ -1048,17 +1107,25 @@ decFromBinding dflags Binding {..} = do in patBind bindPat bod patBind :: LPat GhcPs -> LHsExpr GhcPs -> HsBind GhcPs -patBind lhs expr = +patBind lhs expr = #if __GLASGOW_HASKELL__ < 906 PatBind noExt lhs rhs ([], []) #elif __GLASGOW_HASKELL__ < 910 PatBind noExt lhs rhs +#elif __GLASGOW_HASKELL__ >= 914 + PatBind noExtField lhs (HsUnannotated EpPatBind) rhs #else - PatBind noExt lhs (HsNoMultAnn noExt) rhs + PatBind noExtField lhs (HsNoMultAnn noExtField) rhs #endif where rhs :: GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) - rhs = GRHSs emptyComments [gr] $ + rhs = GRHSs emptyComments +#if __GLASGOW_HASKELL__ >= 914 + (gr :| []) +#else + [gr] +#endif + $ #if __GLASGOW_HASKELL__ >= 902 EmptyLocalBinds noExtField #else @@ -1083,6 +1150,9 @@ runCircuitFun loc = varE loc (runCircuitName ?nms) #if __GLASGOW_HASKELL__ < 902 prefixCon :: [arg] -> HsConDetails arg rec prefixCon a = PrefixCon a +#elif __GLASGOW_HASKELL__ >= 914 +prefixCon :: [arg] -> HsConDetails arg rec +prefixCon a = PrefixCon a #else prefixCon :: [arg] -> HsConDetails tyarg arg rec prefixCon a = PrefixCon [] a @@ -1153,7 +1223,11 @@ unsnoc (x:xs) = Just (x:a, b) hsFunTy :: (p ~ GhcPs) => LHsType p -> LHsType p -> HsType p hsFunTy = #if __GLASGOW_HASKELL__ >= 910 - HsFunTy noExt (HsUnrestrictedArrow noExt) +#if __GLASGOW_HASKELL__ >= 914 + HsFunTy noExtField (HsUnannotated (EpArrow noAnn)) +#else + HsFunTy noExtField (HsUnrestrictedArrow noAnn) +#endif #elif __GLASGOW_HASKELL__ >= 904 HsFunTy noExt (HsUnrestrictedArrow $ L NoTokenLoc HsNormalTok) #elif __GLASGOW_HASKELL__ >= 900 @@ -1189,7 +1263,13 @@ tyEq a b = #if __GLASGOW_HASKELL__ < 904 noLoc $ HsOpTy noExtField a (noLoc eqTyCon_RDR) b #else - noLoc $ HsOpTy noAnn NotPromoted a (noLoc eqTyCon_RDR) b + noLoc $ HsOpTy +#if __GLASGOW_HASKELL__ >= 912 + noExtField +#else + noExt +#endif + NotPromoted a (noLoc eqTyCon_RDR) b #endif -- eqTyCon is a special name that has to be exactly correct for ghc to recognise it. In 8.6 this -- lives in PrelNames and is called eqTyCon_RDR, in later ghcs it's from TysWiredIn.