packages feed

th-utilities 0.2.3.1 → 0.2.4.0

raw patch · 4 files changed

+45/−22 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # ChangeLog +## 0.2.4.0++* Compatibility with GHC-8.10++* Behavior change in reification of type family instances. Instead of+  erroring if the instance mentions a kind variable, now just ignores+  it.+ ## 0.2.3.1  * Compatibility with GHC-8.8
src/TH/ReifySimple.hs view
@@ -61,6 +61,9 @@ import           Data.Typeable (Typeable) import           GHC.Generics (Generic) import           Language.Haskell.TH+#if MIN_VERSION_template_haskell(2,16,0)+                                     hiding (reifyType)+#endif import           Language.Haskell.TH.Instances () import           TH.Utilities @@ -260,34 +263,29 @@     FamilyI (ClosedTypeFamilyD (TypeFamilyHead name tvs _result _injectivity) eqns) _ ->         Just $ TypeFamily name (map tyVarBndrName tvs) $ map (goEqn name) eqns     FamilyI (OpenTypeFamilyD (TypeFamilyHead name tvs _result _injectivity)) insts ->-        Just $ TypeFamily name (map tyVarBndrName tvs) $ map go insts+        Just $ TypeFamily name (map tyVarBndrName tvs) $ map (goInst name) insts #else     FamilyI (ClosedTypeFamilyD name tvs _kind eqns) [] ->         Just $ TypeFamily name (map tyVarBndrName tvs) $ map (goEqn name) eqns     FamilyI (FamilyD TypeFam name tvs _kind) insts ->-        Just $ TypeFamily name (map tyVarBndrName tvs) $ map go insts+        Just $ TypeFamily name (map tyVarBndrName tvs) $ map (goInst name) insts #endif     _ -> Nothing   where #if MIN_VERSION_template_haskell(2,15,0)-    goEqn _ (TySynEqn _ lhs ty)-      | ConT name:params <- unAppsT lhs-      = TypeInst name params ty-      | otherwise-      = error $ "Unexpected type family instance head: " ++ pprint lhs+    toParams ps (AppT ty p) = toParams (p : ps) ty+    toParams ps (AppKindT ty _) = toParams ps ty+    toParams ps _ = ps+    goEqn name (TySynEqn _ lty rty) = TypeInst name (toParams [] lty) rty+    goInst name (TySynInstD eqn) = goEqn name eqn+    goInst _ info' = error $+        "Unexpected instance in FamilyI in infoToTypeInsts:\n" ++ pprint info' #else     goEqn name (TySynEqn params ty) = TypeInst name params ty-#endif--#if MIN_VERSION_template_haskell(2,15,0)-    go (TySynInstD (TySynEqn _ lhs ty))-      | ConT name:params <- unAppsT lhs-      = TypeInst name params ty-#else-    go (TySynInstD name (TySynEqn params ty)) = TypeInst name params ty-#endif-    go info' = error $+    goInst name (TySynInstD _ eqn) = goEqn name eqn+    goInst _ info' = error $         "Unexpected instance in FamilyI in infoToTypeInsts:\n" ++ pprint info'+#endif  infoToDataCon :: Info -> Maybe DataCon infoToDataCon info = case info of@@ -325,9 +323,9 @@             DataCon name (tvs0 ++ map tyVarBndrName tvs) (preds0 ++ preds) fields) (conToDataCons con) #if MIN_VERSION_template_haskell(2,11,0)     GadtC ns slots _ ->-        map (\n -> DataCon n [] [] (map (\(_, ty) -> (Nothing, ty)) slots)) ns+        map (\dn -> DataCon dn [] [] (map (\(_, ty) -> (Nothing, ty)) slots)) ns     RecGadtC ns fields _ ->-        map (\n -> DataCon n [] [] (map (\(n, _, ty) -> (Just n, ty)) fields)) ns+        map (\dn -> DataCon dn [] [] (map (\(fn, _, ty) -> (Just fn, ty)) fields)) ns #endif  -- | Like 'reifyDataType', but takes a 'Type' instead of just the 'Name'
src/TH/Utilities.hs view
@@ -152,10 +152,27 @@ -- Without 'ExpLifter', 'lift' tends to just generate code involving -- data construction. With 'ExpLifter', you can put more complicated -- expression into this construction.-data ExpLifter = ExpLifter ExpQ deriving (Typeable)+--+-- Note that this cannot be used in typed quotes, because 'liftTyped'+-- will throw an exception. This is because this hack is incompatible+-- with the type of 'liftTyped', as it would require the generated+-- code to have type 'ExpLifter'.+data ExpLifter = ExpLifter+#if __GLASGOW_HASKELL__ >= 811+  (forall m. Quote m => m Exp)+#else+  ExpQ+#endif+  deriving (Typeable)  instance Lift ExpLifter where   lift (ExpLifter e) = e+#if MIN_VERSION_template_haskell(2,16,0)+  liftTyped = error $ concat+    [ "'liftTyped' is not implemented for 'ExpLifter', "+    , "because it would require the generated code to have type 'ExpLifter'"+    ]+#endif  -- | Print splices generated by a TH splice (the printing will happen -- during compilation, as a GHC warning). Useful for debugging.
th-utilities.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: bda1ef012fe2084207b76af87373ec5568167d027ce8878be222946dc4a82d5b+-- hash: 50c08bc61c9ae9c17ffbb564778e8b933569d268767798c7a9c1a14ee7bed17d  name:           th-utilities-version:        0.2.3.1+version:        0.2.4.0 synopsis:       Collection of useful functions for use with Template Haskell category:       Template Haskell homepage:       https://github.com/fpco/th-utilities#readme