derive 2.6.3 → 2.6.4
raw patch · 9 files changed
+28/−22 lines, 9 filesdep ~haskell-src-extsnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: haskell-src-exts
API changes (from Hackage documentation)
Files
- CHANGES.txt +3/−2
- README.md +2/−1
- derive.cabal +6/−7
- src/Data/Derive/DSL/HSE.hs +2/−2
- src/Data/Derive/UniplateDirect.hs +2/−2
- src/Derive/Derivation.hs +6/−4
- src/Derive/Main.hs +4/−1
- src/Derive/Test.hs +1/−1
- src/Language/Haskell/Convert.hs +2/−2
CHANGES.txt view
@@ -1,5 +1,6 @@-Changelog for Derive-+2.6.4+ Rewrite for haskell-src-exts == 1.20.*+ #27, disable a few more extensions by default (sync with the HLint list) 2.6.3 #24, support GHC 8.2 2.6.2
README.md view
@@ -1,7 +1,8 @@ # Derive [](https://hackage.haskell.org/package/derive) [](https://travis-ci.org/ndmitchell/derive) +**Warning: This package has no official maintainer anymore. Use at your own risk. You may wish to consider the built-in mechanism [`GHC.Generics`](https://hackage.haskell.org/package/base-4.11.1.0/docs/GHC-Generics.html) or libraries such as [`generic-deriving`](https://hackage.haskell.org/package/generic-deriving).** -Data.Derive is a library and a tool for deriving instances for Haskell programs. It is designed to work with custom derivations, SYB and Template Haskell mechanisms. The tool requires GHC, but the generated code is portable to all compilers. We see this tool as a competitor to <a href="http://repetae.net/~john/computer/haskell/DrIFT/">DrIFT</a>.+Data.Derive is a library and a tool for deriving instances for Haskell programs. It is designed to work with custom derivations, SYB and Template Haskell mechanisms. The tool requires GHC, but the generated code is portable to all compilers. We see this tool as a competitor to <a href="http://repetae.net/computer/haskell/DrIFT/">DrIFT</a>. This document proceeds as follows:
derive.cabal view
@@ -1,11 +1,10 @@-cabal-version: >= 1.18-build-type: Default-name: derive-version: 2.6.3+cabal-version: 1.18 build-type: Simple+name: derive+version: 2.6.4 copyright: Neil Mitchell 2006-2017-author: Neil Mitchell <ndmitchell@gmail.com>-maintainer: Neil Mitchell <ndmitchell@gmail.com>+author: Neil Mitchell <ndmitchell@gmail.com> and others+maintainer: None homepage: https://github.com/ndmitchell/derive#readme bug-reports: https://github.com/ndmitchell/derive/issues license: BSD3@@ -38,7 +37,7 @@ base == 4.*, filepath, syb, template-haskell, containers, pretty, directory, process, bytestring,- haskell-src-exts >= 1.18 && < 1.20,+ haskell-src-exts == 1.20.*, transformers >= 0.2, uniplate >= 1.5 && < 1.7
src/Data/Derive/DSL/HSE.hs view
@@ -23,7 +23,7 @@ -- data Sample a = First | Second a a | Third a sample :: Input-sample = DataDecl () (DataType ()) Nothing (DHApp () (DHead () $ name "Sample") (tyVarBind "a")) ctrs Nothing+sample = DataDecl () (DataType ()) Nothing (DHApp () (DHead () $ name "Sample") (tyVarBind "a")) ctrs [] where ctrs = [ctr "First" 0, ctr "Second" 2, ctr "Third" 1] ctr s i = QualConDecl () Nothing Nothing $ ConDecl () (name s) $ replicate i $ tyVar "a"@@ -90,7 +90,7 @@ f [] = fromConstr $ readCon dat "[]" f (x:xs) = fromConstrB (g x (f xs `asTypeOf` res)) $ readCon dat "(:)" dat = dataTypeOf res- + g :: (Data a, Data b) => Output -> a -> b g x xs = r2 where r2 = if typeOf r2 == typeOf xs then coerce xs else fromOutput x
src/Data/Derive/UniplateDirect.hs view
@@ -224,10 +224,10 @@ listCtor = DataDecl () (DataType ()) Nothing (DHApp () (DHead () $ Ident () "[]") (UnkindedVar () $ Ident () "a")) [QualConDecl () Nothing Nothing $ ConDecl () (Ident () "[]") []- ,QualConDecl () Nothing Nothing $ ConDecl () (Ident () "(:)") [tyVar "a", TyList () $ tyVar "a"]] Nothing+ ,QualConDecl () Nothing Nothing $ ConDecl () (Ident () "(:)") [tyVar "a", TyList () $ tyVar "a"]] [] tupleDefn :: Int -> Decl ()-tupleDefn n = DataDecl () (DataType ()) Nothing dhead [QualConDecl () Nothing Nothing $ ConDecl () (Ident () s) (map tyVar vars)] Nothing+tupleDefn n = DataDecl () (DataType ()) Nothing dhead [QualConDecl () Nothing Nothing $ ConDecl () (Ident () s) (map tyVar vars)] [] where s = "(" ++ replicate (n - 1) ',' ++ ")" vars = ['v':show i | i <- [1..n]] dhead = foldr (flip (DHApp ())) (DHead () $ Ident () s) (map (UnkindedVar () . Ident ()) vars)
src/Derive/Derivation.hs view
@@ -31,15 +31,17 @@ moduleDerives :: Module () -> [Type ()]-moduleDerives = concatMap f . moduleDecls +moduleDerives = concatMap f . moduleDecls where f (DataDecl _ _ _ (fromDeclHead -> (name, vars)) _ deriv) = g name vars deriv f (GDataDecl _ _ _ (fromDeclHead -> (name, vars)) _ _ deriv) = g name vars deriv- f (DerivDecl _ _ (fromIParen -> IRule _ _ _ (fromInstHead -> (name, args)))) = [TyCon () name `tyApps` args]+ f (DerivDecl _ _ _ (fromIParen -> IRule _ _ _ (fromInstHead -> (name, args)))) = [TyCon () name `tyApps` args] f _ = [] - g name vars deriv = [TyCon () a `tyApps` (b:bs) | IRule _ _ _ (fromInstHead -> (a,bs)) <- map fromIParen $ maybe [] (\(Deriving _ xs) -> xs) deriv]+ g name vars deriv = [TyCon () a `tyApps` (b:bs) | IRule _ _ _ (fromInstHead -> (a,bs)) <- map fromIParen $ f deriv] where b = TyCon () (UnQual () name) `tyApps` map (tyVar . prettyPrint) vars+ f [Deriving _ _ xs] = xs+ f _ = [] ---------------------------------------------------------------------@@ -85,7 +87,7 @@ writeDerive file modu flags xs = do -- force the output first, ensure that we don't crash half way through () <- length (concat xs) `seq` return ()- + let append = Append `elem` flags let output = [x | Output x <- flags]
src/Derive/Main.hs view
@@ -60,5 +60,8 @@ [Arrows -- steals proc ,TransformListComp -- steals the group keyword ,XmlSyntax, RegularPatterns -- steals a-b+ ,UnboxedTuples -- breaks (#) lens operator+ ,QuasiQuotes -- breaks [x| ...], making whitespace free list comps break+ ,DoRec, RecursiveDo -- breaks rec+ ,TypeApplications -- HSE fails on @ patterns ]-
src/Derive/Test.hs view
@@ -34,7 +34,7 @@ ,QualConDecl () Nothing Nothing (ConDecl () (Ident () "Cons") [TyVar () (Ident () "a") ,TyApp () (TyCon () (UnQual () (Ident () "List"))) (TyVar () (Ident () "a"))])]- Nothing+ [] -- test each derivation
src/Language/Haskell/Convert.hs view
@@ -44,13 +44,13 @@ NewtypeD cxt n vs _ con ds -> f (NewType ()) cxt n vs [con] ds where f :: DataOrNew () -> Cxt -> TH.Name -> [TyVarBndr] -> [Con] -> unused -> HS.Decl ()- f t cxt n vs con _ = DataDecl () t (Just $ c cxt) (dh (c n) (c vs)) (c con) Nothing+ f t cxt n vs con _ = DataDecl () t (Just $ c cxt) (dh (c n) (c vs)) (c con) [] #else DataD cxt n vs con ds -> f (DataType ()) cxt n vs con ds NewtypeD cxt n vs con ds -> f (NewType ()) cxt n vs [con] ds where f :: DataOrNew () -> Cxt -> TH.Name -> [TyVarBndr] -> [Con] -> [TH.Name] -> HS.Decl ()- f t cxt n vs con ds = DataDecl () t (Just $ c cxt) (dh (c n) (c vs)) (c con) Nothing+ f t cxt n vs con ds = DataDecl () t (Just $ c cxt) (dh (c n) (c vs)) (c con) [] #endif dh name [] = DHead () name