packages feed

deriving-compat 0.4.3 → 0.5

raw patch · 5 files changed

+31/−13 lines, 5 filesdep ~containersdep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: containers, template-haskell

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,14 @@+### 0.5 [2018.07.01]+* Backport the changes to `GeneralizedNewtypeDeriving` and `DerivingVia` code+  generation from+  [Trac #15290](https://ghc.haskell.org/trac/ghc/ticket/15290).++  As a result, code generated by `deriveGND` or `deriveVia` now requires the+  `InstanceSigs` language extension. On the other hand, the generated code+  no longer requires the `ImpredicativeTypes` extension (unless any class+  methods use higher-rank types).+* Allow building with `containers-0.6` and `template-haskell-2.14`.+ ### 0.4.3 [2018.06.16] * Fix a bug that caused debug-enabled GHC builds to panic when generating   code from this library (see
deriving-compat.cabal view
@@ -1,5 +1,5 @@ name:                deriving-compat-version:             0.4.3+version:             0.5 synopsis:            Backports of GHC deriving extensions description:         Provides Template Haskell functions that mimic deriving                      extensions that were introduced or modified in recent versions@@ -71,6 +71,7 @@                    , GHC == 8.0.2                    , GHC == 8.2.2                    , GHC == 8.4.3+                   , GHC == 8.6.1 cabal-version:       >=1.10  source-repository head@@ -120,7 +121,7 @@                        Text.Show.Deriving.Internal                         Paths_deriving_compat-  build-depends:       containers          >= 0.1   && < 0.6+  build-depends:       containers          >= 0.1   && < 0.7                      , ghc-prim                      , th-abstraction      >= 0.2.2 && < 1 @@ -131,7 +132,7 @@     build-depends:     base                >= 4.3   && < 4.9    if flag(template-haskell-2-11)-    build-depends:     template-haskell    >= 2.11  && < 2.14+    build-depends:     template-haskell    >= 2.11  && < 2.15                      , ghc-boot-th   else     build-depends:     template-haskell    >= 2.5   && < 2.11@@ -167,7 +168,7 @@                      , hspec               >= 1.8                      , QuickCheck          >= 2     && < 3                      , tagged              >= 0.7   && < 1-                     , template-haskell    >= 2.5   && < 2.14+                     , template-haskell    >= 2.5   && < 2.15   build-tool-depends:  hspec-discover:hspec-discover >= 1.8    if flag(base-4-9)
src/Data/Deriving/Via.hs view
@@ -42,7 +42,9 @@   require you to enable some language extensions (besides @TemplateHaskell@).   These may include: -    * @ImpredicativeTypes@+    * @ImpredicativeTypes@ (if any class methods contain higher-rank types)++    * @InstanceSigs@      * @KindSignatures@ 
src/Data/Deriving/Via/Internal.hs view
@@ -122,15 +122,15 @@                               Nothing -> etaReductionError instanceTy                           Nothing -> fail $ "Not a newtype: " ++ nameBase dataName                       _ -> fail $ "Not a data type: " ++ pprint dataTy-              catMaybes `fmap` traverse (deriveViaDec clsTvbs clsArgs repTy) clsDecs+              concat . catMaybes <$> traverse (deriveViaDecs' clsTvbs clsArgs repTy) clsDecs             (_, _) -> fail $ "Cannot derive instance for nullary class " ++ pprint clsTy         _ -> fail $ "Not a type class: " ++ pprint clsTy     _ -> fail $ "Malformed instance: " ++ pprint instanceTy -deriveViaDec :: [TyVarBndr] -> [Type] -> Type -> Dec -> Q (Maybe Dec)-deriveViaDec clsTvbs clsArgs repTy = go+deriveViaDecs' :: [TyVarBndr] -> [Type] -> Type -> Dec -> Q (Maybe [Dec])+deriveViaDecs' clsTvbs clsArgs repTy = go   where-    go :: Dec -> Q (Maybe Dec)+    go :: Dec -> Q (Maybe [Dec])      go (OpenTypeFamilyD (TypeFamilyHead tfName tfTvbs _ _)) =       let lhsSubst = zipTvbSubst clsTvbs clsArgs@@ -140,18 +140,21 @@           tfRHSTys = map (applySubstitution rhsSubst) tfTvbTys           tfRHSTy  = applyTy (ConT tfName) tfRHSTys           tfInst   = TySynInstD tfName (TySynEqn tfLHSTys tfRHSTy)-      in return (Just tfInst)+      in return (Just [tfInst])      go (SigD methName methTy) =       let (fromTy, toTy) = mkCoerceClassMethEqn clsTvbs clsArgs repTy $                            stripOuterForallT methTy-          rhsExpr = VarE coerceValName `AppTypeE` fromTy-                                       `AppTypeE` toTy+          fromTau = stripOuterForallT fromTy+          toTau   = stripOuterForallT toTy+          rhsExpr = VarE coerceValName `AppTypeE` fromTau+                                       `AppTypeE` toTau                                        `AppE`     VarE methName+          sig  = SigD methName toTy           meth = ValD (VarP methName)                       (NormalB rhsExpr)                       []-      in return (Just meth)+      in return (Just [sig, meth])      go _ = return Nothing 
tests/DerivingViaSpec.hs view
@@ -9,6 +9,7 @@  #if MIN_VERSION_template_haskell(2,12,0) {-# LANGUAGE ImpredicativeTypes #-}+{-# LANGUAGE InstanceSigs #-} {-# LANGUAGE TypeApplications #-} #endif