packages feed

flexible-defaults 0.0.0.2 → 0.0.0.3

raw patch · 2 files changed

+12/−40 lines, 2 filesdep +th-extrasPVP ok

version bump matches the API change (PVP)

Dependencies added: th-extras

API changes (from Hackage documentation)

Files

flexible-defaults.cabal view
@@ -1,6 +1,6 @@ name:                   flexible-defaults-version:                0.0.0.2-stability:              experimental+version:                0.0.0.3+stability:              provisional  cabal-version:          >= 1.6 build-type:             Simple@@ -28,21 +28,15 @@                         when multiple possible choices could be made, the                         library can choose the \"best\" one.                         .+                        Changes in v0.0.0.3:  Added a hack to fix under GHC 7.2.+                        .                         Changes in v0.0.0.2:  Nothing at all except setting                          'buildable: False' under GHC 7.2.1.-                        Technically it builds on 7.2.1, but it doesn't actually generate-                        correct code due to http://hackage.haskell.org/trac/ghc/ticket/5410-                        which has been patched and will almost certainly be fixed in the next-                        GHC release.  AFAIK 7.2.1 is the only release where this bug actually-                        caused problems.  I'm sure it could be worked around, but it's a -                        whole lot easier to just say "wait for 7.2.2/7.4".  If anyone -                        desperately needs this package under 7.2.1, let me know and I'll-                        see what I can do.  extra-source-files:     examples/*.hs -tested-with:            GHC == 6.8.3, GHC == 6.10.4, GHC == 6.12.1,-                        GHC == 6.12.3, GHC == 7.0.1, GHC == 7.0.2+tested-with:            GHC == 6.8.3, GHC == 6.10.4, GHC == 6.12.3,+                        GHC == 7.0.4, GHC == 7.2.1, GHC == 7.2.2  source-repository head   type:                 git@@ -57,6 +51,5 @@   build-depends:        base >= 3 && <5,                         containers,                         template-haskell,+                        th-extras,                         transformers-  if impl(ghc == 7.2.1)-    buildable:          False
src/Language/Haskell/TH/FlexibleDefaults.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} -- |A code-generation system for complex typeclass default-implementation -- configurations.  There are usage examples in this package's source  -- distribution[1] and in the random-source package[2].@@ -30,41 +29,21 @@ import qualified Data.Map as M import qualified Data.Set as S import Language.Haskell.TH+import Language.Haskell.TH.Extras import Language.Haskell.TH.FlexibleDefaults.DSL import Language.Haskell.TH.FlexibleDefaults.Solve -declaredValueNames :: Dec -> [Name]-declaredValueNames (FunD n _)    = [n]-declaredValueNames (ValD p _ _)  = matchedNames p-declaredValueNames _ = []--matchedNames :: Pat -> [Name]-matchedNames (VarP n)           = [n]-matchedNames (TupP ps)          = concatMap matchedNames ps-matchedNames (InfixP p1 _ p2)   = matchedNames p1 ++ matchedNames p2-matchedNames (TildeP p)         = matchedNames p-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 612-matchedNames (BangP p)          = matchedNames p-#endif-matchedNames (AsP n p)          = n : matchedNames p-matchedNames (RecP _ fs)        = concatMap (matchedNames . snd) fs-matchedNames (ListP ps)         = concatMap matchedNames ps-matchedNames (SigP p _)         = matchedNames p-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 700-matchedNames (ViewP _ p)        = matchedNames p-#endif-matchedNames _                  = []- deleteKeys :: Ord k => S.Set k -> M.Map k v -> M.Map k v deleteKeys ks m = m M.\\ M.fromDistinctAscList [(k,()) | k <- S.toAscList ks]  -- |Given a partial list of function declarations, complete that list based on -- the 'Defaults' specification given. implementDefaults :: (Ord s, Monoid s) => Defaults s () -> [Dec] -> Q [Dec]-implementDefaults defs decs = do-    let prob = toProblem defs+implementDefaults defs futzedDecs = do+    let decs = genericalizeDecs futzedDecs+        prob = toProblem defs         -        implemented = S.fromList (map nameBase (concatMap declaredValueNames decs))+        implemented = S.fromList (map nameBase (concatMap namesBoundInDec decs))         unimplemented = deleteKeys implemented prob                  solutions = chooseImplementations unimplemented