th-lift 0.2 → 0.3
raw patch · 3 files changed
+27/−17 lines, 3 filesdep ~basedep ~template-haskellnew-uploader
Dependency ranges changed: base, template-haskell
Files
- Changelog +5/−2
- Language/Haskell/TH/Lift.hs +15/−7
- th-lift.cabal +7/−8
Changelog view
@@ -1,5 +1,8 @@+2010-03-24 Mathieu Boespflug <mboes@tweag.net> -0.1 6/9/2006:+ * Port to Template Haskell 2.4.+ * Maintainer is now Mathieu Boespflug. -* Initial release.+2006-09-06 Ian Lynagh <igloo@earth.li> + * Initial release.
Language/Haskell/TH/Lift.hs view
@@ -2,22 +2,24 @@ module Language.Haskell.TH.Lift where import GHC.Exts-import Data.PackedString import Language.Haskell.TH import Language.Haskell.TH.Syntax modName :: String modName = "Language.Haskell.TH.Lift" -deriveLift :: Name -> Q Dec+deriveLift :: Name -> Q [Dec] deriveLift n = do i <- reify n case i of- TyConI (DataD _ _ vs cons _) ->- let ctxt = cxt [conT ''Lift `appT` varT v | v <- vs]+ TyConI (DataD _ _ vsk cons _) ->+ let unTyVarBndr (PlainTV v) = v+ unTyVarBndr (KindedTV v _) = v+ vs = map unTyVarBndr vsk+ ctxt = cxt [classP ''Lift [varT v] | v <- vs] typ = foldl appT (conT n) $ map varT vs fun = funD 'lift (map doCons cons)- in instanceD ctxt (conT ''Lift `appT` typ) [fun]+ in instanceD ctxt (conT ''Lift `appT` typ) [fun] >>= return . (:[]) _ -> error (modName ++ ".deriveLift: unhandled: " ++ pprint i) doCons :: Con -> Q Clause@@ -32,8 +34,14 @@ instance Lift Name where lift (Name occName nameFlavour) = [| Name occName nameFlavour |] -instance Lift PackedString where- lift ps = [| packString $(lift $ unpackPS ps) |]+instance Lift OccName where+ lift n = [| mkOccName $(lift $ occString n) |]++instance Lift PkgName where+ lift n = [| mkPkgName $(lift $ pkgString n) |]++instance Lift ModName where+ lift n = [| mkModName $(lift $ modString n) |] instance Lift NameFlavour where lift NameS = [| NameS |]
th-lift.cabal view
@@ -1,20 +1,19 @@ Name: th-lift-Version: 0.2+Version: 0.3+Cabal-Version: >= 1.3 License: OtherLicense License-File: COPYING Copyright: Ian Lynagh, 2006 Author: Ian Lynagh-Maintainer: igloo@earth.li-Stability: experimental+Maintainer: Mathieu Boespflug <mboes@tweag.net> Synopsis: Derive Template Haskell's Lift class for datatypes. Description: Derive Template Haskell's Lift class for datatypes. Category: Language-Tested-With: GHC==6.6-Build-Depends: base, template-haskell-Extensions: TemplateHaskell--- Can't see an extension for I#-ghc-options: -fglasgow-exts+Tested-With: GHC==6.12+Build-Depends: base >= 4 && < 5, template-haskell >= 2.4+Extensions: TemplateHaskell, MagicHash+build-type: Simple Extra-source-files: BSD3, GPL-2, Changelog, Foo.hs, Test.hs Exposed-modules: Language.Haskell.TH.Lift