deriving-compat 0.3.1 → 0.3.2
raw patch · 5 files changed
+47/−13 lines, 5 filesdep ~deriving-compatdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: deriving-compat, template-haskell
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- README.md +1/−1
- deriving-compat.cabal +7/−3
- src/Data/Deriving/Internal.hs +8/−8
- src/Data/Ord/Deriving/Internal.hs +26/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+### 0.3.2+* Incorporate a fix to GHC Trac #10858, which will be introduced in GHC 8.2+* Fix bug in which derived `Ord` instances accidentally swapped their less-than(-or-equal-to) and greater-than(-or-equal-to) methods+* Fix GHC HEAD build+ ### 0.3.1 * Allow deriving `Functor` and `Foldable` instances for datatypes containing unboxed tuples * Microoptimization in derived instances of higher-order versions of `Eq`, `Ord`, `Read`, and `Show`
README.md view
@@ -26,7 +26,7 @@ * In GHC 8.0, `DeriveFoldable` was changed to allow folding over data types with existential constraints. * In GHC 8.0, `DeriveFoldable` and `DeriveTraversable` were changed so as not to generate superfluous `mempty` or `pure` expressions in generated code. As a result, this allows deriving `Traversable` instances for datatypes with unlifted argument types. * In GHC 8.0, deriving `Show` was changed so that constructor fields with unlifted types are no longer shown with parentheses, and the output of showing an unlifted type is suffixed with the same number of hash signs as the corresponding primitive literals.-* In GHC 8.2, deriving `Ord` was changed so that it generates concrete `if`-expressions that are not subject to `RebindableSyntax`.+* In GHC 8.2, deriving `Ord` was changed so that it generates concrete `if`-expressions that are not subject to `RebindableSyntax`. It was also changed so that derived `(<=)`, `(>)`, and `(>=)` methods are expressed through `(<)`, which avoids generating a substantial amount of code. Note that some recent GHC extensions are not covered by this package:
deriving-compat.cabal view
@@ -1,5 +1,5 @@ name: deriving-compat-version: 0.3.1+version: 0.3.2 synopsis: Backports of GHC deriving extensions description: Provides Template Haskell functions that mimic deriving extensions that were introduced or modified in recent versions@@ -28,7 +28,10 @@ number of hash signs as the corresponding primitive literals. . * In GHC 8.2, deriving `Ord` was changed so that it generates concrete- @if@-expressions that are not subject to @RebindableSyntax@.+ @if@-expressions that are not subject to @RebindableSyntax@. It was+ also changed so that derived @(<=)@, @(>)@, and @(>=)@ methods are+ expressed through @(<)@, which avoids generating a substantial+ amount of code. . Note that some recent GHC extensions are not covered by this package: .@@ -137,9 +140,10 @@ Types.ReadShow build-depends: base-compat >= 0.8.1 && < 1 , base-orphans >= 0.5 && < 1- , deriving-compat == 0.3.1+ , deriving-compat == 0.3.2 , hspec >= 1.8 , QuickCheck >= 2 && < 3+ , template-haskell >= 2.5 && < 2.12 if flag(base-4-9) build-depends: base >= 4.9 && < 5
src/Data/Deriving/Internal.hs view
@@ -1769,16 +1769,16 @@ eqValName = mkNameG_v "ghc-prim" "GHC.Classes" "==" geValName :: Name-geValName = mkNameG_v "ghc-prim" "GHC.Classes" "<="+geValName = mkNameG_v "ghc-prim" "GHC.Classes" ">=" gtValName :: Name-gtValName = mkNameG_v "ghc-prim" "GHC.Classes" "<"+gtValName = mkNameG_v "ghc-prim" "GHC.Classes" ">" leValName :: Name-leValName = mkNameG_v "ghc-prim" "GHC.Classes" ">="+leValName = mkNameG_v "ghc-prim" "GHC.Classes" "<=" ltValName :: Name-ltValName = mkNameG_v "ghc-prim" "GHC.Classes" ">"+ltValName = mkNameG_v "ghc-prim" "GHC.Classes" "<" notValName :: Name notValName = mkNameG_v "ghc-prim" "GHC.Classes" "not"@@ -1808,16 +1808,16 @@ eqValName = mkNameG_v "base" "GHC.Classes" "==" geValName :: Name-geValName = mkNameG_v "base" "GHC.Classes" "<="+geValName = mkNameG_v "base" "GHC.Classes" ">=" gtValName :: Name-gtValName = mkNameG_v "base" "GHC.Classes" "<"+gtValName = mkNameG_v "base" "GHC.Classes" ">" leValName :: Name-leValName = mkNameG_v "base" "GHC.Classes" ">="+leValName = mkNameG_v "base" "GHC.Classes" "<=" ltValName :: Name-ltValName = mkNameG_v "base" "GHC.Classes" ">"+ltValName = mkNameG_v "base" "GHC.Classes" "<" notValName :: Name notValName = mkNameG_v "base" "GHC.Classes" "not"
src/Data/Ord/Deriving/Internal.hs view
@@ -177,9 +177,34 @@ makeFunD oFun = funD (ordFunName oFun $ arity oClass) [ clause []- (normalB $ makeOrdFunForCons oFun cons)+ (normalB $ dispatchFun oFun) [] ]++ negateExpr :: Q Exp -> Q Exp+ negateExpr = appE (varE notValName)++ dispatchLT :: (Q Exp -> Q Exp -> Q Exp -> Q Exp) -> Q Exp+ dispatchLT f = do+ x <- newName "x"+ y <- newName "y"+ lamE [varP x, varP y] $ f (varE ltValName) (varE x) (varE y)++ dispatchFun :: OrdFun -> Q Exp+ dispatchFun oFun | oFun `elem` [ OrdCompare, OrdLT+ -- OrdLT is included to mirror the fix to+ -- GHC Trac #10858.+#if defined(NEW_FUNCTOR_CLASSES)+ , Ord1LiftCompare, Ord2LiftCompare2+#else+ , Ord1Compare1+#endif+ ]+ = makeOrdFunForCons oFun cons+ dispatchFun OrdLE = dispatchLT $ \lt x y -> negateExpr $ lt `appE` y `appE` x+ dispatchFun OrdGT = dispatchLT $ \lt x y -> lt `appE` y `appE` x+ dispatchFun OrdGE = dispatchLT $ \lt x y -> negateExpr $ lt `appE` x `appE` y+ dispatchFun _ = fail "ordFunDecs" -- | Generates a lambda expression which behaves like the OrdFun value. This -- function uses heuristics to determine whether to implement the OrdFun from