derive-storable-plugin 0.2.3.3 → 0.2.3.4
raw patch · 10 files changed
+407/−98 lines, 10 filesdep ~ghcdep ~ghciPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghc, ghci
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- derive-storable-plugin.cabal +4/−4
- src/Foreign/Storable/Generic/Plugin.hs +5/−0
- src/Foreign/Storable/Generic/Plugin/Internal.hs +36/−5
- src/Foreign/Storable/Generic/Plugin/Internal/Compile.hs +98/−23
- src/Foreign/Storable/Generic/Plugin/Internal/Error.hs +9/−0
- src/Foreign/Storable/Generic/Plugin/Internal/GroupTypes.hs +48/−10
- src/Foreign/Storable/Generic/Plugin/Internal/Helpers.hs +55/−21
- src/Foreign/Storable/Generic/Plugin/Internal/Predicates.hs +68/−11
- src/Foreign/Storable/Generic/Plugin/Internal/Types.hs +80/−24
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for generic-storable-plugin +## 0.2.3.3 -- 2021-07-12++* Adding support for GHC 9.0.1+ ## 0.2.3.3 -- 2020-12-05 * Put a comma in a wrong place.
derive-storable-plugin.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/ name: derive-storable-plugin-version: 0.2.3.3+version: 0.2.3.4 synopsis: GHC core plugin supporting the derive-storable package. description: The package helps derive-storable package in forcing compile time evaluation of sizes, alignments and offsets.@@ -16,7 +16,7 @@ build-type: Simple extra-source-files: ChangeLog.md README.md cabal-version: >=1.10-tested-with: GHC==8.2.2, GHC==8.4.2, GHC==8.6.5, GHC==8.8.1, GHC==8.10.2+tested-with: GHC==8.2.2, GHC==8.4.2, GHC==8.6.5, GHC==8.8.1, GHC==8.10.2,GHC==9.0.1 Flag sumtypes Description: Use sumtypes within benchmark and tests.@@ -32,7 +32,7 @@ , Foreign.Storable.Generic.Plugin.Internal.Predicates , Foreign.Storable.Generic.Plugin.Internal.Types other-extensions: DeriveGeneric, DeriveAnyClass, PatternGuards- build-depends: base >=4.10 && <5, ghc >= 8.2 && < 8.12, ghci >= 8.2 && < 8.12, derive-storable >= 0.3 && < 0.4+ build-depends: base >=4.10 && <5, ghc >= 8.2 && < 9.1, ghci >= 8.2 && < 9.1, derive-storable >= 0.3 && < 0.4 hs-source-dirs: src default-language: Haskell2010 @@ -57,7 +57,7 @@ other-modules: TestCases build-depends: base >= 4.10 && < 5, derive-storable, derive-storable-plugin , hspec >= 2.4, QuickCheck >= 2.10- , ghc >= 8.2 && < 8.12, ghci >= 8.2 && < 8.12+ , ghc >= 8.2 && < 9.1, ghci >= 8.2 && < 9.1 default-language: Haskell2010 if flag(sumtypes)
src/Foreign/Storable/Generic/Plugin.hs view
@@ -18,7 +18,12 @@ {-# LANGUAGE CPP #-} module Foreign.Storable.Generic.Plugin (plugin) where ++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Plugins+#else import GhcPlugins+#endif import Data.Maybe
src/Foreign/Storable/Generic/Plugin/Internal.hs view
@@ -9,6 +9,7 @@ Contains methods for calculating type ordering and performing the compile-substitution optimisation. -}+{-#LANGUAGE CPP #-} module Foreign.Storable.Generic.Plugin.Internal ( groupTypes@@ -18,37 +19,67 @@ -- Management of Core. import Prelude hiding ((<>))++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,Id, modifyInlinePragma, setInlinePragma, idInfo)+import GHC.Types.Id.Info+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName)+import GHC.Types.SrcLoc (noSrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr, getHscEnv)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad+ (CoreM, CoreToDo(..), + getHscEnv, getDynFlags, putMsg, putMsgS)+import GHC.Types.Basic (CompilerPhase(..))+import GHC.Core.Type (isAlgType, splitTyConApp_maybe)+import GHC.Core.TyCon (tyConKind, algTyConRhs, visibleDataCons)+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..))+import GHC.Builtin.Types (intDataCon)+import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable + (cat, ppr, SDoc, showSDocUnsafe, showSDoc, + ($$), ($+$), hsep, vcat, empty,text, + (<>), (<+>), nest, int, colon,hcat, comma, + punctuate, fsep) +import GHC.Core.Opt.Monad (putMsg, putMsgS)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt) import Literal (Literal(..)) import Id (isLocalId, isGlobalId,Id, modifyInlinePragma, setInlinePragma, idInfo)-import IdInfo +import IdInfo import Var (Var(..)) import Name (getOccName,mkOccName) import OccName (OccName(..), occNameString) import qualified Name as N (varName) import SrcLoc (noSrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..)) import CoreMonad (CoreM, CoreToDo(..), getHscEnv, getDynFlags, putMsg, putMsgS) import BasicTypes (CompilerPhase(..))--- Haskell types import Type (isAlgType, splitTyConApp_maybe) import TyCon (tyConKind, algTyConRhs, visibleDataCons) import TyCoRep (Type(..), TyBinder(..)) import TysWiredIn (intDataCon) import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe, showSDoc, ($$), ($+$), hsep, vcat, empty,text, (<>), (<+>), nest, int, colon,hcat, comma, punctuate, fsep) +import CoreMonad (putMsg, putMsgS)+#endif+ import Data.List
src/Foreign/Storable/Generic/Plugin/Internal/Compile.hs view
@@ -39,49 +39,118 @@ where --- Management of Core. import Prelude hiding ((<>))++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt, AltCon(..), isId, Unfolding(..))+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,setIdInfo, Id)+import GHC.Types.Id.Info (IdInfo(..))+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName,getSrcSpan)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName)+import GHC.Types.SrcLoc (noSrcSpan,SrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad (CoreM,CoreToDo(..),getHscEnv,getDynFlags)+import GHC.Core.Lint (lintExpr)+import GHC.Types.Basic (CompilerPhase(..), Boxity(..))+import GHC.Core.Type+import GHC.Core.TyCon (algTyConRhs, visibleDataCons)+import GHC.Builtin.Types +import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable (cat, ppr, SDoc, showSDocUnsafe)+import GHC.Utils.Outputable (Outputable(..),($$), ($+$), vcat, empty,text, (<>), (<+>), nest, int, comma) +import GHC.Core.Opt.Monad (putMsg, putMsgS)+import GHC.Builtin.Names (buildIdKey, augmentIdKey)+import GHC.Builtin.Types.Prim (intPrimTy)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt, AltCon(..), isId, Unfolding(..)) import Literal (Literal(..))-#if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)-import Literal (LitNumType(..))-#endif-import Id (isLocalId, isGlobalId,setIdInfo,Id)+import Id (isLocalId, isGlobalId,setIdInfo, Id) import IdInfo (IdInfo(..))-import Var (Var(..), idInfo)-import Name (getOccName,mkOccName, getSrcSpan)+import Var (Var(..))+import Name (getOccName,mkOccName,getSrcSpan) import OccName (OccName(..), occNameString)-import qualified Name as N (varName, tvName, tcClsName)-import SrcLoc (noSrcSpan, SrcSpan)+import qualified Name as N (varName)+import SrcLoc (noSrcSpan,SrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..)) import CoreMonad (CoreM,CoreToDo(..), getHscEnv, getDynFlags) import CoreLint (lintExpr)-import BasicTypes (CompilerPhase(..))--- Haskell types +import BasicTypes (CompilerPhase(..), Boxity(..)) import Type (isAlgType, splitTyConApp_maybe)-import TyCon (tyConName, algTyConRhs, visibleDataCons)-import TyCoRep (Type(..), TyBinder(..), TyLit(..))-import TysWiredIn-import TysPrim (intPrimTy)+import TyCon (algTyConRhs, visibleDataCons)+import TysWiredIn import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe) import Outputable (Outputable(..),($$), ($+$), vcat, empty,text, (<>), (<+>), nest, int, comma) import CoreMonad (putMsg, putMsgS)+import PrelNames (buildIdKey, augmentIdKey)+import TysPrim (intPrimTy)+#endif ++ -- Used to get to compiled values import GHCi.RemoteTypes --- Used to create types-import PrelNames (buildIdKey, augmentIdKey)-import DataCon (dataConWorkId)-import BasicTypes (Boxity(..)) +#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Var (TyVarBinder(..), VarBndr(..))+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..), TyCoBinder(..),scaledThing)+import GHC.Types.Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)+import Var (TyVarBinder(..), VarBndr(..))+import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))+import Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)+import Var (TyVarBndr(..), TyVarBinder)+import TyCoRep (Type(..), TyBinder(..))+import Var+#endif++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Literal (LitNumType(..))+#elif MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)+import Literal (LitNumType(..))+#endif++-- Management of Core.+-- import Prelude hiding ((<>))+-- import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt, AltCon(..), isId, Unfolding(..))+-- import Literal (Literal(..))+-- #if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)+-- import Literal (LitNumType(..))+-- #endif+-- import Id (isLocalId, isGlobalId,setIdInfo,Id)+-- import IdInfo (IdInfo(..))+-- import Var (Var(..), idInfo)+-- import Name (getOccName,mkOccName, getSrcSpan)+-- import OccName (OccName(..), occNameString)+-- import qualified Name as N (varName, tvName, tcClsName)+-- import SrcLoc (noSrcSpan, SrcSpan)+-- import Unique (getUnique)+-- -- Compilation pipeline stuff+-- import HscMain (hscCompileCoreExpr)+-- import HscTypes (HscEnv,ModGuts(..))+-- import CoreMonad (CoreM,CoreToDo(..), getHscEnv, getDynFlags)+-- import CoreLint (lintExpr)+-- import BasicTypes (CompilerPhase(..))+-- -- Haskell types +-- import Type (isAlgType, splitTyConApp_maybe)+-- import TyCon (tyConName, algTyConRhs, visibleDataCons)+-- import TyCoRep (Type(..), TyBinder(..), TyLit(..))+-- import TysWiredIn+-- import TysPrim (intPrimTy)+-- import DataCon (dataConWorkId,dataConOrigArgTys) ++ import Unsafe.Coerce import Data.List@@ -128,7 +197,9 @@ -- | A small helper - create an integer literal. intLiteral :: (Integral a) => a -> CoreExpr-#if MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+intLiteral i = Lit $ LitNumber LitNumInt (fromIntegral i)+#elif MIN_VERSION_GLASGOW_HASKELL(8,6,0,0) intLiteral i = Lit $ LitNumber LitNumInt (fromIntegral i) intPrimTy #else intLiteral i = Lit $ MachInt $ fromIntegral i@@ -140,7 +211,11 @@ where fun = Var $ dataConWorkId intDataCon -- arg = Lit $ MachInt $ fromIntegral i arg = intLiteral i+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ wild= mkWildValBinder Many t +#else wild= mkWildValBinder t +#endif -- | For gsizeOf and galignment - calculate the variables. intSubstitution :: CoreBind -> CoreM (Either Error CoreBind)
src/Foreign/Storable/Generic/Plugin/Internal/Error.hs view
@@ -9,6 +9,7 @@ Contains the Error datatype and related pretty print functions. -}+{-# LANGUAGE CPP #-} module Foreign.Storable.Generic.Plugin.Internal.Error ( Verbosity(..) , CrashOnWarning(..)@@ -18,11 +19,19 @@ , stringToPpr ) where +#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Id (Id)+import GHC.Types.Var (Var(..))+import GHC.Core (CoreBind(..), Bind(..),CoreExpr(..))+import GHC.Core.Type (Type)+import GHC.Utils.Outputable+#else import Id (Id) import Var(Var(..)) import CoreSyn (CoreBind(..), Bind(..),CoreExpr(..)) import Type (Type) import Outputable+#endif import Foreign.Storable.Generic.Plugin.Internal.Helpers
src/Foreign/Storable/Generic/Plugin/Internal/GroupTypes.hs view
@@ -8,6 +8,7 @@ Grouping methods, both for types and core bindings. -}+{-# LANGUAGE CPP #-} module Foreign.Storable.Generic.Plugin.Internal.GroupTypes ( -- Type ordering@@ -19,7 +20,30 @@ ) where --- Management of Core.++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,Id)+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName)+import GHC.Types.SrcLoc (noSrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr, getHscEnv)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad (CoreM,CoreToDo(..))+import GHC.Types.Basic (CompilerPhase(..))+import GHC.Core.Type hiding (eqType)+import GHC.Core.TyCon+import GHC.Builtin.Types (intDataCon)+import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable (cat, ppr, SDoc, showSDocUnsafe)+import GHC.Utils.Outputable (text, (<+>), ($$), nest)+import GHC.Core.Opt.Monad (putMsg, putMsgS)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt) import Literal (Literal(..)) import Id (isLocalId, isGlobalId,Id)@@ -29,30 +53,40 @@ import qualified Name as N (varName) import SrcLoc (noSrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..)) import CoreMonad (CoreM,CoreToDo(..), getHscEnv) import BasicTypes (CompilerPhase(..))--- Haskell types -import Type (isAlgType, splitTyConApp_maybe)-import TyCon (algTyConRhs, visibleDataCons)-import TyCoRep (Type(..), TyBinder(..))+import Type hiding (eqType)+import TyCon import TysWiredIn (intDataCon) import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe) import Outputable (text, (<+>), ($$), nest) import CoreMonad (putMsg, putMsgS)+#endif ++ -- Used to get to compiled values import GHCi.RemoteTypes -import TyCon-import Type hiding (eqType) +#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Var (TyVarBinder(..), VarBndr(..))+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..), TyCoBinder(..),scaledThing)+import GHC.Types.Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)+import Var (TyVarBinder(..), VarBndr(..))+import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))+import Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)+import Var (TyVarBndr(..), TyVarBinder)+import TyCoRep (Type(..), TyBinder(..))+import Var+#endif+ import Unsafe.Coerce import Data.List@@ -132,7 +166,11 @@ -- using ty_vars as keys. let type_scope = zip ty_vars ty_args data_cons = concatMap dataConOrigArgTys $ (visibleDataCons.algTyConRhs) tc+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ map (substituteTyCon type_scope) (map scaledThing data_cons) +#else map (substituteTyCon type_scope) data_cons +#endif | otherwise = []
src/Foreign/Storable/Generic/Plugin/Internal/Helpers.hs view
@@ -12,47 +12,72 @@ {-#LANGUAGE CPP#-} module Foreign.Storable.Generic.Plugin.Internal.Helpers where --- Management of Core.+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,Id)+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName)+import GHC.Types.SrcLoc (noSrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr, getHscEnv)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad (CoreM,CoreToDo(..))+import GHC.Types.Basic (CompilerPhase(..))+import GHC.Core.Type (isAlgType, splitTyConApp_maybe)+import GHC.Core.TyCon (algTyConRhs, visibleDataCons)+import GHC.Builtin.Types (intDataCon)+import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable (cat, ppr, SDoc, showSDocUnsafe)+import GHC.Core.Opt.Monad (putMsg, putMsgS)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt) import Literal (Literal(..)) import Id (isLocalId, isGlobalId,Id) import Var (Var(..))-#if MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)-import Var (TyVarBinder(..), VarBndr(..))-#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)-import Var (TyVarBndr(..), TyVarBinder)-#endif import Name (getOccName,mkOccName) import OccName (OccName(..), occNameString) import qualified Name as N (varName) import SrcLoc (noSrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..)) import CoreMonad (CoreM,CoreToDo(..), getHscEnv) import BasicTypes (CompilerPhase(..))--- Haskell types import Type (isAlgType, splitTyConApp_maybe) import TyCon (algTyConRhs, visibleDataCons)-#if MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)-import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))-#else -import TyCoRep (Type(..), TyBinder(..))-#endif import TysWiredIn (intDataCon) import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe) import CoreMonad (putMsg, putMsgS)+#endif ++ -- Used to get to compiled values import GHCi.RemoteTypes +#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Var (TyVarBinder(..), VarBndr(..))+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..), TyCoBinder(..),scaledThing)+import GHC.Types.Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)+import Var (TyVarBinder(..), VarBndr(..))+import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))+import Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)+import Var (TyVarBndr(..), TyVarBinder)+import TyCoRep (Type(..), TyBinder(..))+import Var+#endif ++ import Unsafe.Coerce import Data.List@@ -60,7 +85,6 @@ import Data.Either import Control.Monad.IO.Class -import Var -- | Get ids from core bind.@@ -123,7 +147,9 @@ #else eqTyBind (Named t1 vis1) (Named t2 vis2) = t1 == t2 && vis1 == vis2 #endif-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+eqTyBind (Anon _ t1) (Anon _ t2) = scaledThing t1 `eqType` scaledThing t2+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) eqTyBind (Anon _ t1) (Anon _ t2) = t1 `eqType` t2 #else eqTyBind (Anon t1) (Anon t2) = t1 `eqType` t2@@ -156,7 +182,9 @@ isProxy (Named tycovar flag) #endif | isTyCoVar tycovar-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ bool star <- varType tycovar+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ bool star <- varType tycovar #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy bool star <- varType tycovar@@ -171,7 +199,9 @@ removeProxy t -- forall (proxy :: Bool -> *) | ForAllTy fall t1 <- t-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ ch t2 <- t1+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ ch t2 <- t1 #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy ch t2 <- t1@@ -186,7 +216,9 @@ -- forall (proxy :: Bool -> *) b. | ForAllTy fall f2 <- t , ForAllTy b t1 <- f2-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ ch t2 <- t1+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ ch t2 <- t1 #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy ch t2 <- t1@@ -201,7 +233,9 @@ -- forall b (proxy :: Bool -> *). | ForAllTy b f2 <- t , ForAllTy fall t1 <- f2-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ ch t2 <- t1+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ ch t2 <- t1 #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy ch t2 <- t1
src/Foreign/Storable/Generic/Plugin/Internal/Predicates.hs view
@@ -38,35 +38,92 @@ ) where --- Management of Core.+-- -- Management of Core.+-- import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+-- import Literal (Literal(..))+-- import Id (isLocalId, isGlobalId,Id)+-- import Var (Var(..))+-- import Name (getOccName,mkOccName)+-- import OccName (OccName(..), occNameString)+-- import qualified Name as N (varName, tcClsName)+-- import SrcLoc (noSrcSpan)+-- import Unique (getUnique)+-- -- Compilation pipeline stuff+-- import HscMain (hscCompileCoreExpr)+-- import HscTypes (HscEnv,ModGuts(..))+-- import CoreMonad (CoreM, CoreToDo(..), getHscEnv)+-- import BasicTypes (CompilerPhase(..))+-- -- Types +-- import Type (isAlgType, splitTyConApp_maybe)+-- import TyCon (TyCon,tyConName, algTyConRhs, visibleDataCons)+-- import TyCoRep (Type(..), TyBinder(..))+-- import TysWiredIn (intDataCon)+-- import DataCon (dataConWorkId,dataConOrigArgTys) +-- +-- import MkCore (mkWildValBinder)+-- -- Printing+-- import Outputable (cat, ppr, SDoc, showSDocUnsafe)+-- import CoreMonad (putMsg, putMsgS)++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,Id)+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName)+import GHC.Types.SrcLoc (noSrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr, getHscEnv)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad (CoreM,CoreToDo(..))+import GHC.Types.Basic (CompilerPhase(..))+import GHC.Core.Type (isAlgType, splitTyConApp_maybe)+import GHC.Core.TyCon (algTyConRhs, visibleDataCons)+import GHC.Builtin.Types (intDataCon)+import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable (cat, ppr, SDoc, showSDocUnsafe)+import GHC.Core.Opt.Monad (putMsg, putMsgS)+import GHC.Types.Name (nameStableString)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt) import Literal (Literal(..)) import Id (isLocalId, isGlobalId,Id) import Var (Var(..)) import Name (getOccName,mkOccName) import OccName (OccName(..), occNameString)-import qualified Name as N (varName, tcClsName)+import qualified Name as N (varName) import SrcLoc (noSrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..))-import CoreMonad (CoreM, CoreToDo(..), getHscEnv)+import CoreMonad (CoreM,CoreToDo(..), getHscEnv) import BasicTypes (CompilerPhase(..))--- Types import Type (isAlgType, splitTyConApp_maybe)-import TyCon (TyCon,tyConName, algTyConRhs, visibleDataCons)-import TyCoRep (Type(..), TyBinder(..))+import TyCon (algTyConRhs, visibleDataCons) import TysWiredIn (intDataCon) import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe) import CoreMonad (putMsg, putMsgS)-- import Name (nameStableString)+#endif++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Var (TyVarBinder(..), VarBndr(..))+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..), TyCoBinder(..),scaledThing)+import GHC.Types.Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)+import Var (TyVarBinder(..), VarBndr(..))+import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))+import Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)+import Var (TyVarBndr(..), TyVarBinder)+import TyCoRep (Type(..), TyBinder(..))+import Var+#endif import Data.Maybe
src/Foreign/Storable/Generic/Plugin/Internal/Types.hs view
@@ -37,43 +37,55 @@ ) where --- Management of Core.++++#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt)+import GHC.Types.Literal (Literal(..))+import GHC.Types.Id (isLocalId, isGlobalId,Id)+import GHC.Types.Var (Var(..))+import GHC.Types.Name (getOccName,mkOccName)+import GHC.Types.Name.Occurrence (OccName(..), occNameString)+import qualified GHC.Types.Name as N (varName, tcClsName)+import GHC.Types.SrcLoc (noSrcSpan)+import GHC.Types.Unique (getUnique)+import GHC.Driver.Main (hscCompileCoreExpr, getHscEnv)+import GHC.Driver.Types (HscEnv,ModGuts(..))+import GHC.Core.Opt.Monad (CoreM,CoreToDo(..))+import GHC.Types.Basic (CompilerPhase(..))+import GHC.Core.Type (isAlgType, splitTyConApp_maybe)+import GHC.Core.TyCon (TyCon(..),algTyConRhs, visibleDataCons)+import GHC.Builtin.Types (intDataCon)+import GHC.Core.DataCon (dataConWorkId,dataConOrigArgTys) +import GHC.Core.Make (mkWildValBinder)+import GHC.Utils.Outputable (cat, ppr, SDoc, showSDocUnsafe)+import GHC.Core.Opt.Monad (putMsg, putMsgS)+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) import CoreSyn (Bind(..),Expr(..), CoreExpr, CoreBind, CoreProgram, Alt) import Literal (Literal(..)) import Id (isLocalId, isGlobalId,Id)-import Var (Var(..), isId)-#if MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)-import Var (TyVarBinder, VarBndr(..), binderVar)-#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)-import Var (TyVarBndr(..), TyVarBinder, binderVar)-#endif+import Var (Var(..)) import Name (getOccName,mkOccName) import OccName (OccName(..), occNameString)-import qualified Name as N (varName,tcClsName)+import qualified Name as N (varName, tcClsName) import SrcLoc (noSrcSpan) import Unique (getUnique)--- Compilation pipeline stuff import HscMain (hscCompileCoreExpr) import HscTypes (HscEnv,ModGuts(..))-import CoreMonad (CoreM, CoreToDo(..), getHscEnv)+import CoreMonad (CoreM,CoreToDo(..), getHscEnv) import BasicTypes (CompilerPhase(..))--- Haskell types import Type (isAlgType, splitTyConApp_maybe) import TyCon (TyCon(..),algTyConRhs, visibleDataCons)-import TyCoRep (Type(..), TyBinder(..)) import TysWiredIn (intDataCon) import DataCon (dataConWorkId,dataConOrigArgTys) - import MkCore (mkWildValBinder)--- Printing import Outputable (cat, ppr, SDoc, showSDocUnsafe) import CoreMonad (putMsg, putMsgS)+#endif --- Used to get to compiled values import GHCi.RemoteTypes -- import Unsafe.Coerce import Data.List@@ -88,12 +100,33 @@ -- Function for getting types from an id.+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Core.TyCon (isUnboxedTupleTyCon)+import GHC.Builtin.Types (intTyCon, constraintKind, constraintKindTyCon, listTyCon, intTy)+import GHC.Builtin.Names (ioTyConKey, ptrTyConKey, realWorldTyConKey, statePrimTyConKey)+import GHC.Core.Type (isUnboxedTupleType)+#else import TyCon (isUnboxedTupleTyCon) import TysWiredIn (intTyCon, constraintKind, constraintKindTyCon, listTyCon, intTy) import PrelNames (ioTyConKey, ptrTyConKey, realWorldTyConKey, statePrimTyConKey) import Type (isUnboxedTupleType)+#endif +#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+import GHC.Types.Var (TyVarBinder(..), VarBndr(..))+import GHC.Core.TyCo.Rep (Type(..), TyBinder(..), TyCoBinder(..),scaledThing)+import GHC.Types.Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,8,1,0)+import Var (TyVarBinder(..), VarBndr(..))+import TyCoRep (Type(..), TyBinder(..), TyCoBinder(..))+import Var+#elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)+import Var (TyVarBndr(..), TyVarBinder)+import TyCoRep (Type(..), TyBinder(..))+import Var+#endif+ -- | Check whether the type is integer isIntType :: Type -> Bool isIntType (TyConApp int []) = int == intTyCon@@ -185,7 +218,12 @@ getAlignmentType t -- Assuming there are no anonymous ty bind between -- the type and the integer, ie no : Type -> forall a. Int-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ | FunTy _ _ t1 t2 <- t+ -- , isIntType t2+ , TyConApp _ _ <- t2+ , the_t <- t1+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) | FunTy _ t1 t2 <- t -- , isIntType t2 , TyConApp _ _ <- t2@@ -208,7 +246,12 @@ getSizeType t -- Assuming there are no anonymous ty bind between -- the type and the integer, ie no : Type -> forall a. Int-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ | FunTy _ _ t1 t2 <- t+ -- , isIntType t2+ , TyConApp _ _ <- t2+ , the_t <- t1+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) | FunTy _ t1 t2 <- t -- , isIntType t2 , TyConApp _ _ <- t2@@ -247,7 +290,9 @@ = Just the_t -- Int -> IO (TheType) | after_ptr-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ int_t io_t <- t+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ int_t io_t <- t #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy int_t io_t <- t@@ -258,8 +303,11 @@ , isIntType int_t = getPeekType' io_t True True -- Ptr b -> Int -> IO (TheType)-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0) | ForAllTy ty_bind fun_t <- t+ , FunTy _ _ ptr_t rest <- fun_t +#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+ | ForAllTy ty_bind fun_t <- t , FunTy _ ptr_t rest <- fun_t #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) | ForAllTy ty_bind fun_t <- t@@ -292,7 +340,10 @@ getPokeType' t after_ptr after_int -- Last step: TheType -> IO () | after_ptr, after_int-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ , FunTy _ _ the_t io_t <- t+ , isIOType io_t+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ the_t io_t <- t , isIOType io_t #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)@@ -306,7 +357,9 @@ = Just the_t -- Int -> TheType -> IO () | after_ptr-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9, 0,1,0)+ , FunTy _ _ int_t rest <- t+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) , FunTy _ int_t rest <- t #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0) , FunTy int_t rest <- t@@ -317,7 +370,10 @@ , isIntType int_t = getPokeType' rest True True -- Ptr b -> Int -> TheType -> IO ()-#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)+#if MIN_VERSION_GLASGOW_HASKELL(9,0,1,0)+ | ForAllTy ty_bind fun_t <- t+ , FunTy _ _ ptr_t rest <- fun_t+#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) | ForAllTy ty_bind fun_t <- t , FunTy _ ptr_t rest <- fun_t #elif MIN_VERSION_GLASGOW_HASKELL(8,2,1,0)