regular-extras 0.1.2 → 0.2.0
raw patch · 3 files changed
+69/−6 lines, 3 filesdep +deepseqdep ~regularPVP ok
version bump matches the API change (PVP)
Dependencies added: deepseq
Dependency ranges changed: regular
API changes (from Hackage documentation)
+ Generics.Regular.Functions.Seq: class Seq f
+ Generics.Regular.Functions.Seq: gdseq :: (Regular a, Seq (PF a)) => a -> b -> b
+ Generics.Regular.Functions.Seq: gseq :: (Seq f) => (a -> b -> b) -> f a -> b -> b
+ Generics.Regular.Functions.Seq: instance (NFData a) => Seq (K a)
+ Generics.Regular.Functions.Seq: instance (Seq f) => Seq (C c f)
+ Generics.Regular.Functions.Seq: instance (Seq f) => Seq (S s f)
+ Generics.Regular.Functions.Seq: instance (Seq f, Seq g) => Seq (f :*: g)
+ Generics.Regular.Functions.Seq: instance (Seq f, Seq g) => Seq (f :+: g)
+ Generics.Regular.Functions.Seq: instance Seq I
+ Generics.Regular.Functions.Seq: instance Seq U
Files
- examples/Test.hs +4/−0
- regular-extras.cabal +8/−6
- src/Generics/Regular/Functions/Seq.hs +57/−0
examples/Test.hs view
@@ -12,6 +12,7 @@ import Generics.Regular import Generics.Regular.Functions.Arbitrary import Generics.Regular.Functions.Binary+import Generics.Regular.Functions.Seq import Test.QuickCheck (quickCheck, sized, elements, generate, Gen) import qualified Test.QuickCheck as Q (Arbitrary(..))@@ -88,3 +89,6 @@ propL :: Logic -> Bool propL x = runGet gget (runPut (gput x)) == x in quickCheck propC >> quickCheck propL++-- Testing deep seq+ex4 = gdseq (Not (T :->: (error "deep seq works"))) ()
regular-extras.cabal view
@@ -1,5 +1,5 @@ name: regular-extras-version: 0.1.2+version: 0.2.0 synopsis: Additional functions for regular: arbitrary, coarbitrary, and binary get/put. description:@@ -11,7 +11,7 @@ \[1] <http://hackage.haskell.org/package/regular> category: Generics-copyright: (c) 2009 Universiteit Utrecht+copyright: (c) 2010 Universiteit Utrecht license: BSD3 license-file: LICENSE author: Jose Pedro Magalhaes,@@ -20,7 +20,7 @@ stability: experimental build-type: Custom cabal-version: >= 1.2.1-tested-with: GHC == 6.10.4+tested-with: GHC == 6.10.4, GHC == 6.12.1 extra-source-files: examples/Test.hs ChangeLog @@ -28,10 +28,12 @@ library hs-source-dirs: src exposed-modules: Generics.Regular.Functions.Arbitrary,- Generics.Regular.Functions.Binary+ Generics.Regular.Functions.Binary,+ Generics.Regular.Functions.Seq other-modules: Generics.Regular.Functions.Fixpoints - build-depends: base >= 4.0 && < 5, regular >= 0.2 && < 0.3,- QuickCheck == 1.2.0.0, binary >= 0.2+ build-depends: base >= 4.0 && < 5, regular >= 0.3 && < 0.4,+ QuickCheck == 1.2.0.0, binary >= 0.2,+ deepseq < 2 ghc-options: -Wall
+ src/Generics/Regular/Functions/Seq.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}++-----------------------------------------------------------------------------+-- |+-- Module : Generics.Regular.Functions.Seq+-- Copyright : (c) 2009 Universiteit Utrecht+-- License : BSD3+--+-- Maintainer : generics@haskell.org+-- Stability : experimental+-- Portability : non-portable+--+-- Summary: Deep generic seq. Used to fully evaluate a term.+-----------------------------------------------------------------------------++module Generics.Regular.Functions.Seq (+ + Seq(..), gdseq+ + ) where++import Control.DeepSeq+import Generics.Regular.Base++-- | The class for generic deep seq.+class Seq f where+ gseq :: (a -> b -> b) -> f a -> b -> b++instance Seq I where+ gseq f (I x) = f x++-- | For constants we rely on the |DeepSeq| class.+instance (NFData a) => Seq (K a) where+ gseq _ (K x) = deepseq x+ +instance Seq U where+ gseq _ U = id++instance (Seq f, Seq g) => Seq (f :+: g) where+ gseq f (L x) = gseq f x+ gseq f (R y) = gseq f y++instance (Seq f, Seq g) => Seq (f :*: g) where+ gseq f (x :*: y) = gseq f x . gseq f y++instance Seq f => Seq (C c f) where+ gseq f (C x) = gseq f x++instance Seq f => Seq (S s f) where+ gseq f (S x) = gseq f x+++-- | Deep, generic version of seq.+gdseq :: (Regular a, Seq (PF a)) => a -> b -> b+gdseq p = gseq gdseq (from p)