deepseq-th 0.1.0.3 → 0.1.0.4
raw patch · 3 files changed
+41/−9 lines, 3 filesdep ~basedep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, template-haskell
API changes (from Hackage documentation)
Files
- Control/DeepSeq/TH.hs +25/−3
- deepseq-th.cabal +11/−6
- test-whnf-is-nf.hs +5/−0
Control/DeepSeq/TH.hs view
@@ -1,6 +1,11 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP, TemplateHaskell #-} --- |Module providing Template Haskell based 'NFData' instance+-- |+-- Module : Control.DeepSeq.TH+-- Stability : experimental+-- Portability : GHC+--+-- Module providing Template Haskell based 'NFData' instance -- generators and WHNF=NF type inspectors. -- -- To use this module enable the @TemplateHaskell@ extension and@@ -50,6 +55,7 @@ TyConI dec -> decWhnfIsNf2 (x:seen) dec _ -> return Nothing +typeWhnfIsNf2 _ (TupleT 0) = return $ Just True -- () typeWhnfIsNf2 _ (AppT (AppT ArrowT _) _) = return $ Just True -- a -> b typeWhnfIsNf2 _ (AppT ListT _) = return $ Just False -- [a] typeWhnfIsNf2 _ (AppT (TupleT _) _) = return $ Just False -- (a,b,...)@@ -98,9 +104,13 @@ return $ reduce ms | otherwise = return $ Just False where- allStrict = all (== IsStrict) fStricts+ allStrict = all isStrictOrUnpacked fStricts (fStricts, fTypes) = unzip $ con2types con + isStrictOrUnpacked NotStrict = False+ isStrictOrUnpacked IsStrict = True+ isStrictOrUnpacked Unpacked = True+ con2types (NormalC _ ts) = ts con2types (RecC _ vts) = [ (tst,tt) | (_,tst,tt) <- vts ] con2types (InfixC tl _ tr) = [tl,tr]@@ -218,6 +228,9 @@ hlp (IsStrict, fieldType) = do tmp <- typeWhnfIsNf fieldType return $ if fromMaybe False tmp then Nothing else Just fieldType+ hlp (Unpacked, fieldType) = do+ tmp <- typeWhnfIsNf fieldType+ return $ if fromMaybe False tmp then Nothing else Just fieldType -- |Plural version of 'deriveNFData' --@@ -240,6 +253,15 @@ getFreeTyVars (TupleT _) = mzero getFreeTyVars (UnboxedTupleT _) = mzero getFreeTyVars (VarT n) = return n+#if MIN_VERSION_template_haskell(2,8,0)+getFreeTyVars (PromotedT _) = error "getFreeTyVars: PromotedT not supported yet"+getFreeTyVars (PromotedTupleT _)= error "getFreeTyVars: PromotedTupleT not supported yet"+getFreeTyVars (PromotedNilT) = error "getFreeTyVars: PromotedNilT not supported yet"+getFreeTyVars (PromotedConsT) = error "getFreeTyVars: PromotedConstT not supported yet"+getFreeTyVars (StarT) = error "getFreeTyVars: StarT not supported yet"+getFreeTyVars (LitT _) = error "getFreeTyVars: LitT not supported yet"+getFreeTyVars (ConstraintT) = error "getFreeTyVars: ConstraintT not supported yet"+#endif -- helper mkDeepSeqExpr :: [Name] -> Exp
deepseq-th.cabal view
@@ -1,5 +1,5 @@ name: deepseq-th-version: 0.1.0.3+version: 0.1.0.4 license: BSD3 license-file: LICENSE maintainer: hvr@gnu.org@@ -11,9 +11,12 @@ deriving optimised NFData instances for custom data types. See documentation in "Control.DeepSeq.TH" for more information. .+ See also the @deepseq-generics@ package+ (<http://hackage.haskell.org/package/deepseq-generics>) for a less+ experimental approach. build-type: Simple cabal-version: >=1.10-tested-with: GHC>=7.2.1+tested-with: GHC>=7.4.1 source-repository head type: git@@ -21,20 +24,22 @@ library default-language: Haskell2010+ other-extensions: CPP, TemplateHaskell exposed-modules: Control.DeepSeq.TH build-depends:- base >= 4.4 && < 4.6,+ base >= 4.4 && < 4.7, deepseq >= 1.1 && < 1.4,- template-haskell >= 2.6 && < 2.8+ template-haskell >= 2.7 && < 2.9 ghc-options: -Wall test-suite test-whnf-is-nf default-language: Haskell2010+ other-extensions: CPP, TemplateHaskell type: exitcode-stdio-1.0 main-is: test-whnf-is-nf.hs other-modules: Test.WhnfIsNf build-depends:- base >= 4.4 && < 4.6,+ base >= 4.4 && < 4.7, deepseq >= 1.1 && < 1.4,- template-haskell >= 2.6 && < 2.8+ template-haskell >= 2.7 && < 2.9 ghc-options: -Wall
test-whnf-is-nf.hs view
@@ -41,6 +41,10 @@ data Goo = Goo0 | Goo1 !Doo +data EH = EH {-# UNPACK #-} !W64 | EQ {-# NOUNPACK #-} !W64 !Bool++newtype W64 = EA Word64+ main :: IO () main = do posAss("()", ())@@ -72,3 +76,4 @@ negAss("[Int]", [Int]) negAss("[()]", [()]) negAss("Maybe Bool", Maybe Bool)+ posAss("EH", EH)