packages feed

th-lift 0.7.11 → 0.8

raw patch · 4 files changed

+141/−123 lines, 4 filesdep −packedstringdep ~basedep ~template-haskelldep ~th-abstractionPVP ok

version bump matches the API change (PVP)

Dependencies removed: packedstring

Dependency ranges changed: base, template-haskell, th-abstraction

API changes (from Hackage documentation)

- Language.Haskell.TH.Lift: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Data.Functor.Const.Const a b)
- Language.Haskell.TH.Lift: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Data.Functor.Identity.Identity a)

Files

+ CHANGELOG.md view
@@ -0,0 +1,82 @@+# Change Log++All notable changes to this project will be documented in this file.++## [0.8]++* Remove `Lift ()`, `Ratio`, `Identity` and `Const ()` instances.+  These are now provided in [`th-lift-instances` package](http://hackage.haskell.org/package/th-lift-instances)+- Use `TemplateHaskellQuotes` where available++## [0.7.11] - 2018-08-27++* Support for GHC 8.6.++## [0.7.10] - 2018-02-01++* Add support for data families++## [0.7.9] - 2018-02-01++* `Lift` instances for `Identity` and `Const`.++## [0.7.8] - 2018-02-01++* GHC 8.4 compatibility.++## [0.7.7] - 2015-04-19++* GHC 8.2 compatibility.++## [0.7.6] - 2015-01-18++* GHC 8.1 compatibility.++## [0.7.5] - 2015-11-19++* Added `makeLift`, for cases when it's necessary to write the+  instance manually. (Thanks to Ryan Scott).+* Support empty datatypes and unboxed types.++## [0.7] - 2014-12-07++* Support GHC 7.9 and hopefully 7.10, thanks to Richard Eisenberg.+* On versions of GHC that support role inference, don't constrain+  phantom type variables.+* Get rid of some orphan instances when using GHC >= 7.9.++## [0.6] - 2013-12-09++* Support GHC 7.8, thanks to Michael Snoyberg.+* Support existentially quantified type variables in datatype+  declarations.+* Handle exotic kinds properly.++## [0.5.2] - 2010-09-19++* Support older GHCs and Cabal, thanks to Ben Millwood.++## [0.5] - 2010-08-05++* Support for contexts in datatypes, thanks to Ben Millwood.+* `deriveLiftWith` becomes `deriveLift'` and takes an `Info`+  structure rather than a custom reification function.+* Add `deriveLiftMany` to derive many `Lift` instances in one go.++## [0.4] - 2010-08-02++* Add support for newtypes and records syntax, thanks to a patch by+  Ben Millwood.+* Add support for infix constructors.+* `deriveLift` returns a list of declarations.+* New `deriveLiftWith` function with custom reification, following+  a feature request by Jonas Duregård.++## [0.3] - 2010-03-24++* Port to Template Haskell 2.4.+* Maintainer is now Mathieu Boespflug.++## [0.2] - 2006-09-06++Initial release by Ian Lynagh.
− Changelog
@@ -1,52 +0,0 @@-2015-01-18  Mathieu Boespflug <mboes@tweag.net>--	* GHC 8.1 compatibility.--2015-11-19  Mathieu Boespflug <mboes@tweag.net>--	* Added makeLift, for cases when it's necessary to write the-	instance manually. (Thanks to Ryan Scott).-	* Support empty datatypes and unboxed types.--2014-12-07  Mathieu Boespflug <mboes@tweag.net>--	* Support GHC 7.9 and hopefully 7.10, thanks to Richard Eisenberg.-	* On versions of GHC that support role inference, don't constrain-	phantom type variables.-	* Get rid of some orphan instances when using GHC >= 7.9.--2013-12-09  Mathieu Boespflug <mboes@tweag.net>--	* Support GHC 7.8, thanks to Michael Snoyberg.-	* Support existentially quantified type variables in datatype-	declarations.-	* Handle exotic kinds properly.--2010-09-19  Mathieu Boespflug <mboes@tweag.net>--	* Support older GHCs and Cabal, thanks to Ben Millwood.--2010-08-05  Mathieu Boespflug <mboes@tweag.net>--	* Support for contexts in datatypes, thanks to Ben Millwood.-	* deriveLiftWith becomes deriveLift' and takes an Info structure-	rather than a custom reification function.-	* Add deriveLiftMany to derive many Lift instances in one go.--2010-08-02  Mathieu Boespflug <mboes@tweag.net>--	* Add support for newtypes and records syntax, thanks to a patch-	by Ben Millwood.-	* Add support for infix constructors.-	* deriveLift returns a list of declarations.-	* New deriveLiftWith function with custom reification, following a-	feature request by Jonas Duregård.--2010-03-24  Mathieu Boespflug <mboes@tweag.net>--	* Port to Template Haskell 2.4.-	* Maintainer is now Mathieu Boespflug.--2006-09-06  Ian Lynagh <igloo@earth.li>--	* Initial release.
src/Language/Haskell/TH/Lift.hs view
@@ -1,8 +1,12 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MagicHash #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeSynonymInstances #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes #-}+#else+{-# LANGUAGE TemplateHaskell #-}+#endif  {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -16,10 +20,6 @@   , Lift(..)   ) where -#if !(MIN_VERSION_template_haskell(2,4,0))-import Data.PackedString (PackedString, packString, unpackPS)-#endif /* MIN_VERSION_template_haskell(2,4,0) */- import GHC.Base (unpackCString#) import GHC.Exts (Double(..), Float(..), Int(..), Word(..)) import GHC.Prim (Addr#, Double#, Float#, Int#, Word#)@@ -155,7 +155,7 @@ consMatches :: Name -> [ConstructorInfo] -> [Q Match] consMatches n [] = [match wildP (normalB e) []]   where-    e = [| errorQExp $(stringE ("Can't lift value of empty datatype " ++ nameBase n)) |]+    e = varE 'errorQExp `appE` (stringE $ "Can't lift value of empty datatype " ++ nameBase n) consMatches _ cons = concatMap doCons cons  doCons :: ConstructorInfo -> [Q Match]@@ -167,10 +167,10 @@     let con = [| conE c |]     case (variant, ns, ts) of       (InfixConstructor, [x0, x1], [t0, t1]) ->-        let e = [| infixApp $(liftVar x0 t0) $con $(liftVar x1 t1) |]+        let e = varE 'infixApp `appE` liftVar x0 t0 `appE` con `appE` liftVar x1 t1         in match (infixP (varP x0) c (varP x1)) (normalB e) []       (_, _, _) ->-        let e = foldl (\e1 e2 -> [| appE $e1 $e2 |]) con $ zipWith liftVar ns ts+        let e = foldl (\e1 e2 -> varE 'appE `appE` e1 `appE` e2) con $ zipWith liftVar ns ts         in match (conP c (map varP ns)) (normalB e) []  #if MIN_VERSION_template_haskell(2,9,0)@@ -186,31 +186,41 @@ liftVar :: Name -> Type -> Q Exp liftVar varName (ConT tyName) #if MIN_VERSION_template_haskell(2,8,0)-  | tyName == ''Addr#   = [| litE (stringPrimL (map (fromIntegral . ord)-                                                    (unpackCString# $var))) |]+  | tyName == ''Addr#   = apps+    [ varE 'litE, varE 'stringPrimL, varE 'map, [| fromIntegral . ord |]+    , varE 'unpackCString# ] #else /* !(MIN_VERSION_template_haskell(2,8,0)) */-  | tyName == ''Addr#   = [| litE (stringPrimL (unpackCString# $var))       |]+  | tyName == ''Addr#   = apps+    [ varE 'litE, varE 'stringPrimL, varE 'unpackCString# ] #endif #if MIN_VERSION_template_haskell(2,11,0)-  | tyName == ''Char#   = [| litE (charPrimL               (C# $var))  |]+  | tyName == ''Char#   = apps [ varE 'litE, varE 'charPrimL, conE 'C# ] #endif  /* !(MIN_VERSION_template_haskell(2,11,0)) */-  | tyName == ''Double# = [| litE (doublePrimL (toRational (D# $var))) |]-  | tyName == ''Float#  = [| litE (floatPrimL  (toRational (F# $var))) |]-  | tyName == ''Int#    = [| litE (intPrimL    (toInteger  (I# $var))) |]-  | tyName == ''Word#   = [| litE (wordPrimL   (toInteger  (W# $var))) |]+  | tyName == ''Double# = apps [ varE 'litE, varE 'doublePrimL, varE 'toRational, conE 'D# ]+  | tyName == ''Float#  = apps [ varE 'litE, varE 'floatPrimL,  varE 'toRational, conE 'F# ]+  | tyName == ''Int#    = apps [ varE 'litE, varE 'intPrimL,    varE 'toInteger,  conE 'I# ]+  | tyName == ''Word#   = apps [ varE 'litE, varE 'wordPrimL,   varE 'toInteger,  conE 'W# ]+   where+    apps  = foldr appE var+     var :: Q Exp     var = varE varName-liftVar varName _ = [| lift $(varE varName) |] +liftVar varName _ = varE 'lift `appE` varE varName+ withInfo :: DatatypeInfo          -> (Cxt -> Name -> [Type] -> [ConstructorInfo] -> Q a)          -> Q a withInfo i f = case i of-    DatatypeInfo { datatypeContext = dcx-                 , datatypeName    = n-                 , datatypeVars    = vs-                 , datatypeCons    = cons+    DatatypeInfo { datatypeContext   = dcx+                 , datatypeName      = n+#if MIN_VERSION_th_abstraction(0,3,0)+                 , datatypeInstTypes = vs+#else+                 , datatypeVars      = vs+#endif+                 , datatypeCons      = cons                  } ->       f dcx n vs cons @@ -225,19 +235,15 @@  #if MIN_VERSION_template_haskell(2,4,0) instance Lift OccName where-  lift n = [| mkOccName $(lift $ occString n) |]+  lift n = [| mkOccName |] `appE` lift (occString n)  instance Lift PkgName where-  lift n = [| mkPkgName $(lift $ pkgString n) |]+  lift n = [| mkPkgName |] `appE` lift (pkgString n)  instance Lift ModName where-  lift n = [| mkModName $(lift $ modString n) |]--#else /* MIN_VERSION_template_haskell(2,4,0) */-instance Lift PackedString where-  lift ps = [| packString $(lift $ unpackPS ps) |]-+  lift n = [| mkModName |] `appE` lift (modString n) #endif /* MIN_VERSION_template_haskell(2,4,0) */+ instance Lift NameFlavour where   lift NameS = [| NameS |]   lift (NameQ modnam) = [| NameQ modnam |]@@ -257,21 +263,3 @@   lift VarName = [| VarName |]   lift DataName = [| DataName |]   lift TcClsName = [| TcClsName |]--#if !(MIN_VERSION_template_haskell(2,10,0))--- These instances should really go in the template-haskell package.--instance Lift () where-  lift _ = [| () |]--instance Integral a => Lift (Ratio a) where-  lift x = return (LitE (RationalL (toRational x)))-#endif--#if MIN_VERSION_base(4,8,0)-instance Lift a => Lift (Identity a) where-  lift = appE (conE 'Identity) . lift . runIdentity-#endif--instance Lift a => Lift (Const a b) where-  lift = appE (conE 'Const) . lift . getConst
th-lift.cabal view
@@ -1,6 +1,6 @@ Name:               th-lift-Version:            0.7.11-Cabal-Version:      >= 1.8+Version:            0.8+Cabal-Version:      1.12 License:            BSD3 License-Files:      COPYING, BSD3, GPL-2 Copyright:          © 2006 Ian Lynagh, © 2010-2018 Mathieu Boespflug@@ -9,42 +9,42 @@ Homepage:           http://github.com/mboes/th-lift Synopsis:           Derive Template Haskell's Lift class for datatypes. Description:-  Derive Template Haskell's Lift class for datatypes.+  Derive Template Haskell's Lift class for datatypes using @TemplateHaskell@+  .+  * <https://hackage.haskell.org/package/th-orphans th-orphans> package provides instances for @template-haskell@ syntax types+  .+  * <http://hackage.haskell.org/package/th-lift-instances th-lift-instances> package provides @Lift@ (compat) instances for types in @base@, @text@, @bytestring@, @vector@ etc. Category:           Language-Tested-With:        GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.2+Tested-With:        GHC==7.0.4, GHC==7.2.2, GHC==7.4.2, GHC==7.6.3, GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.1 build-type:         Simple-Extra-source-files: Changelog+Extra-source-files: CHANGELOG.md  source-repository head   type:     git   location: git://github.com/mboes/th-lift  Library-  Exposed-modules: Language.Haskell.TH.Lift-  Extensions:      CPP, TemplateHaskell, MagicHash, TypeSynonymInstances, FlexibleInstances-  Hs-Source-Dirs:  src-  Build-Depends:   base >= 3 && < 5,-                   ghc-prim,-                   th-abstraction >= 0.2.3--  ghc-options:     -Wall-  if impl(ghc < 6.12)-    Build-Depends: packedstring == 0.1.*,-                   template-haskell >= 2.2 && < 2.4+  Default-Language: Haskell2010+  Exposed-modules:  Language.Haskell.TH.Lift+  Other-Extensions: CPP,  MagicHash, TypeSynonymInstances, FlexibleInstances+  if impl(ghc >= 8.0)+    Other-Extensions: TemplateHaskellQuotes   else-    Build-Depends: template-haskell >= 2.4 && < 2.15+    Other-Extensions: TemplateHaskell+  Hs-Source-Dirs:   src+  Build-Depends:    base              >= 4.3  && < 5,+                    ghc-prim,+                    th-abstraction   >= 0.2.3 && < 0.4,+                    template-haskell >= 2.4   && < 2.15  Test-Suite test+  Default-Language: Haskell2010   Type:             exitcode-stdio-1.0   Main-Is:          Test.hs   Hs-Source-Dirs:   t   other-modules:    Foo   ghc-options:      -Wall-  Build-Depends:    base >= 3 && < 5,+  Build-Depends:    base,                     ghc-prim,-                    th-lift-  if impl(ghc < 6.12)-    Build-Depends: packedstring == 0.1.*,-                   template-haskell >= 2.2 && < 2.4-  else-    Build-Depends: template-haskell >= 2.4 && < 2.15+                    th-lift,+                    template-haskell