compdata-0.8.0.1: Compositional Data Types

Copyright(c) 2010-2011 Patrick Bahr
LicenseBSD3
MaintainerPatrick Bahr <paba@diku.dk>
Stabilityexperimental
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell98

Data.Comp.Derive

Contents

Description

This module contains functionality for automatically deriving boilerplate code using Template Haskell. Examples include instances of Functor, Foldable, and Traversable.

Synopsis

Documentation

derive :: [Name -> Q [Dec]] -> [Name] -> Q [Dec] Source

Helper function for generating a list of instances for a list of named signatures. For example, in order to derive instances Functor and ShowF for a signature Exp, use derive as follows (requires Template Haskell):

$(derive [makeFunctor, makeShowF] [''Exp])

Derive boilerplate instances for compositional data type signatures.

ShowF

class ShowF f where Source

Signature printing. An instance ShowF f gives rise to an instance Show (Term f).

Methods

showF :: f String -> String Source

Instances

ShowF [] 
ShowF Maybe 
Show a0 => ShowF ((,) a) 
(ShowF f, Show p) => ShowF ((:&:) f p) 
(ShowF f, ShowF g) => ShowF ((:+:) f g) 
(Functor f, ShowF f) => ShowF (Cxt h f) 

makeShowF :: Name -> Q [Dec] Source

Derive an instance of ShowF for a type constructor of any first-order kind taking at least one argument.

class ShowConstr f where Source

Constructor printing.

Methods

showConstr :: f a -> String Source

Instances

makeShowConstr :: Name -> Q [Dec] Source

Derive an instance of showConstr for a type constructor of any first-order kind taking at least one argument.

EqF

class EqF f where Source

Signature equality. An instance EqF f gives rise to an instance Eq (Term f).

Methods

eqF :: Eq a => f a -> f a -> Bool Source

Instances

EqF [] 
EqF Maybe 
Eq a0 => EqF ((,) a) 
(Eq a0, Eq b0) => EqF ((,,) a b) 
(EqF f, EqF g) => EqF ((:+:) f g)

EqF is propagated through sums.

EqF f => EqF (Cxt h f) 
(Eq a0, Eq b0, Eq c0) => EqF ((,,,) a b c) 
(Eq a0, Eq b0, Eq c0, Eq d0) => EqF ((,,,,) a b c d) 
(Eq a0, Eq b0, Eq c0, Eq d0, Eq e0) => EqF ((,,,,,) a b c d e) 
(Eq a0, Eq b0, Eq c0, Eq d0, Eq e0, Eq f0) => EqF ((,,,,,,) a b c d e f) 
(Eq a0, Eq b0, Eq c0, Eq d0, Eq e0, Eq f0, Eq g0) => EqF ((,,,,,,,) a b c d e f g) 
(Eq a0, Eq b0, Eq c0, Eq d0, Eq e0, Eq f0, Eq g0, Eq h0) => EqF ((,,,,,,,,) a b c d e f g h) 
(Eq a0, Eq b0, Eq c0, Eq d0, Eq e0, Eq f0, Eq g0, Eq h0, Eq i0) => EqF ((,,,,,,,,,) a b c d e f g h i) 

makeEqF :: Name -> Q [Dec] Source

Derive an instance of EqF for a type constructor of any first-order kind taking at least one argument.

OrdF

class EqF f => OrdF f where Source

Signature ordering. An instance OrdF f gives rise to an instance Ord (Term f).

Methods

compareF :: Ord a => f a -> f a -> Ordering Source

Instances

OrdF [] 
OrdF Maybe 
Ord a0 => OrdF ((,) a) 
(Ord a0, Ord b0) => OrdF ((,,) a b) 
(OrdF f, OrdF g) => OrdF ((:+:) f g)

OrdF is propagated through sums.

OrdF f => OrdF (Cxt h f) 
(Ord a0, Ord b0, Ord c0) => OrdF ((,,,) a b c) 
(Ord a0, Ord b0, Ord c0, Ord d0) => OrdF ((,,,,) a b c d) 
(Ord a0, Ord b0, Ord c0, Ord d0, Ord e0) => OrdF ((,,,,,) a b c d e) 
(Ord a0, Ord b0, Ord c0, Ord d0, Ord e0, Ord f0) => OrdF ((,,,,,,) a b c d e f) 
(Ord a0, Ord b0, Ord c0, Ord d0, Ord e0, Ord f0, Ord g0) => OrdF ((,,,,,,,) a b c d e f g) 
(Ord a0, Ord b0, Ord c0, Ord d0, Ord e0, Ord f0, Ord g0, Ord h0) => OrdF ((,,,,,,,,) a b c d e f g h) 
(Ord a0, Ord b0, Ord c0, Ord d0, Ord e0, Ord f0, Ord g0, Ord h0, Ord i0) => OrdF ((,,,,,,,,,) a b c d e f g h i) 

makeOrdF :: Name -> Q [Dec] Source

Derive an instance of OrdF for a type constructor of any first-order kind taking at least one argument.

Functor

class Functor f

The Functor class is used for types that can be mapped over. Instances of Functor should satisfy the following laws:

fmap id  ==  id
fmap (f . g)  ==  fmap f . fmap g

The instances of Functor for lists, Maybe and IO satisfy these laws.

Minimal complete definition

fmap

Instances

Functor [] 
Functor IO 
Functor Q 
Functor Gen 
Functor Id 
Functor ZipList 
Functor Maybe 
Functor Tree 
Functor ModuleName 
Functor SpecialCon 
Functor QName 
Functor Name 
Functor IPName 
Functor QOp 
Functor Op 
Functor CName 
Functor Module 
Functor ModuleHead 
Functor ExportSpecList 
Functor ExportSpec 
Functor Namespace 
Functor ImportDecl 
Functor ImportSpecList 
Functor ImportSpec 
Functor Assoc 
Functor Decl 
Functor TypeEqn 
Functor Annotation 
Functor BooleanFormula 
Functor DataOrNew 
Functor DeclHead 
Functor InstRule 
Functor InstHead 
Functor Deriving 
Functor Binds 
Functor IPBind 
Functor Match 
Functor QualConDecl 
Functor ConDecl 
Functor FieldDecl 
Functor GadtDecl 
Functor ClassDecl 
Functor InstDecl 
Functor BangType 
Functor Rhs 
Functor GuardedRhs 
Functor Type 
Functor Promoted 
Functor TyVarBind 
Functor Kind 
Functor FunDep 
Functor Context 
Functor Asst 
Functor Literal 
Functor Sign 
Functor Exp 
Functor XName 
Functor XAttr 
Functor Bracket 
Functor Splice 
Functor Safety 
Functor CallConv 
Functor ModulePragma 
Functor Overlap 
Functor Activation 
Functor Rule 
Functor RuleVar 
Functor WarningText 
Functor Pat 
Functor PXAttr 
Functor RPatOp 
Functor RPat 
Functor PatField 
Functor Stmt 
Functor QualStmt 
Functor FieldUpdate 
Functor Alt 
Functor Identity 
Functor PprM 
Functor I 
Functor ((->) r) 
Functor (Either a) 
Functor ((,) a) 
Functor (ST s) 
Ix i => Functor (Array i) 
Functor (StateL s) 
Functor (StateR s) 
Functor (Const m) 
Monad m => Functor (WrappedMonad m) 
Arrow a => Functor (ArrowMonad a) 
Functor (Proxy *) 
Functor (Map k) 
Functor m => Functor (ListT m) 
Functor m => Functor (MaybeT m) 
Functor m => Functor (IdentityT m) 
Functor (HashMap k) 
Functor (K a) 
Arrow a => Functor (WrappedArrow a b) 
Functor (ContT r m) 
Functor m => Functor (ErrorT e m) 
Functor m => Functor (ReaderT r m) 
Functor m => Functor (StateT s m) 
Functor m => Functor (StateT s m) 
Functor m => Functor (WriterT w m) 
Functor m => Functor (WriterT w m) 
Functor f => Functor ((:&:) f a) 
(Functor f, Functor g) => Functor ((:+:) f g) 
Functor f => Functor (Cxt h f) 
Functor q => Functor ((:^:) q p) 
Functor m => Functor (RWST r w s m) 
Functor m => Functor (RWST r w s m) 

makeFunctor :: Name -> Q [Dec] Source

Derive an instance of Functor for a type constructor of any first-order kind taking at least one argument.

Foldable

class Foldable t

Data structures that can be folded.

Minimal complete definition: foldMap or foldr.

For example, given a data type

data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)

a suitable instance would be

instance Foldable Tree where
   foldMap f Empty = mempty
   foldMap f (Leaf x) = f x
   foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r

This is suitable even for abstract types, as the monoid is assumed to satisfy the monoid laws. Alternatively, one could define foldr:

instance Foldable Tree where
   foldr f z Empty = z
   foldr f z (Leaf x) = f x z
   foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l

Minimal complete definition

foldMap | foldr

Instances

Foldable [] 
Foldable Maybe 
Foldable Set 
Foldable Tree 
Foldable ModuleName 
Foldable SpecialCon 
Foldable QName 
Foldable Name 
Foldable IPName 
Foldable QOp 
Foldable Op 
Foldable CName 
Foldable Module 
Foldable ModuleHead 
Foldable ExportSpecList 
Foldable ExportSpec 
Foldable Namespace 
Foldable ImportDecl 
Foldable ImportSpecList 
Foldable ImportSpec 
Foldable Assoc 
Foldable Decl 
Foldable TypeEqn 
Foldable Annotation 
Foldable BooleanFormula 
Foldable DataOrNew 
Foldable DeclHead 
Foldable InstRule 
Foldable InstHead 
Foldable Deriving 
Foldable Binds 
Foldable IPBind 
Foldable Match 
Foldable QualConDecl 
Foldable ConDecl 
Foldable FieldDecl 
Foldable GadtDecl 
Foldable ClassDecl 
Foldable InstDecl 
Foldable BangType 
Foldable Rhs 
Foldable GuardedRhs 
Foldable Type 
Foldable Promoted 
Foldable TyVarBind 
Foldable Kind 
Foldable FunDep 
Foldable Context 
Foldable Asst 
Foldable Literal 
Foldable Sign 
Foldable Exp 
Foldable XName 
Foldable XAttr 
Foldable Bracket 
Foldable Splice 
Foldable Safety 
Foldable CallConv 
Foldable ModulePragma 
Foldable Overlap 
Foldable Activation 
Foldable Rule 
Foldable RuleVar 
Foldable WarningText 
Foldable Pat 
Foldable PXAttr 
Foldable RPatOp 
Foldable RPat 
Foldable PatField 
Foldable Stmt 
Foldable QualStmt 
Foldable FieldUpdate 
Foldable Alt 
Foldable Identity 
Foldable HashSet 
Foldable (Either a) 
Foldable ((,) a) 
Ix i => Foldable (Array i) 
Foldable (Const m) 
Foldable (Proxy *) 
Foldable (Map k) 
Foldable f => Foldable (ListT f) 
Foldable f => Foldable (MaybeT f) 
Foldable f => Foldable (IdentityT f) 
Foldable (HashMap k) 
Foldable f => Foldable (ErrorT e f) 
Foldable f => Foldable (WriterT w f) 
Foldable f => Foldable (WriterT w f) 
Foldable f => Foldable ((:&:) f a) 
(Foldable f, Foldable g) => Foldable ((:+:) f g) 
Foldable f => Foldable (Cxt h f) 

makeFoldable :: Name -> Q [Dec] Source

Derive an instance of Foldable for a type constructor of any first-order kind taking at least one argument.

Traversable

class (Functor t, Foldable t) => Traversable t

Functors representing data structures that can be traversed from left to right.

Minimal complete definition: traverse or sequenceA.

A definition of traverse must satisfy the following laws:

naturality
t . traverse f = traverse (t . f) for every applicative transformation t
identity
traverse Identity = Identity
composition
traverse (Compose . fmap g . f) = Compose . fmap (traverse g) . traverse f

A definition of sequenceA must satisfy the following laws:

naturality
t . sequenceA = sequenceA . fmap t for every applicative transformation t
identity
sequenceA . fmap Identity = Identity
composition
sequenceA . fmap Compose = Compose . fmap sequenceA . sequenceA

where an applicative transformation is a function

t :: (Applicative f, Applicative g) => f a -> g a

preserving the Applicative operations, i.e.

and the identity functor Identity and composition of functors Compose are defined as

  newtype Identity a = Identity a

  instance Functor Identity where
    fmap f (Identity x) = Identity (f x)

  instance Applicative Indentity where
    pure x = Identity x
    Identity f <*> Identity x = Identity (f x)

  newtype Compose f g a = Compose (f (g a))

  instance (Functor f, Functor g) => Functor (Compose f g) where
    fmap f (Compose x) = Compose (fmap (fmap f) x)

  instance (Applicative f, Applicative g) => Applicative (Compose f g) where
    pure x = Compose (pure (pure x))
    Compose f <*> Compose x = Compose ((<*>) <$> f <*> x)

(The naturality law is implied by parametricity.)

Instances are similar to Functor, e.g. given a data type

data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)

a suitable instance would be

instance Traversable Tree where
   traverse f Empty = pure Empty
   traverse f (Leaf x) = Leaf <$> f x
   traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r

This is suitable even for abstract types, as the laws for <*> imply a form of associativity.

The superclass instances should satisfy the following:

Minimal complete definition

traverse | sequenceA

Instances

Traversable [] 
Traversable Maybe 
Traversable Tree 
Traversable ModuleName 
Traversable SpecialCon 
Traversable QName 
Traversable Name 
Traversable IPName 
Traversable QOp 
Traversable Op 
Traversable CName 
Traversable Module 
Traversable ModuleHead 
Traversable ExportSpecList 
Traversable ExportSpec 
Traversable Namespace 
Traversable ImportDecl 
Traversable ImportSpecList 
Traversable ImportSpec 
Traversable Assoc 
Traversable Decl 
Traversable TypeEqn 
Traversable Annotation 
Traversable BooleanFormula 
Traversable DataOrNew 
Traversable DeclHead 
Traversable InstRule 
Traversable InstHead 
Traversable Deriving 
Traversable Binds 
Traversable IPBind 
Traversable Match 
Traversable QualConDecl 
Traversable ConDecl 
Traversable FieldDecl 
Traversable GadtDecl 
Traversable ClassDecl 
Traversable InstDecl 
Traversable BangType 
Traversable Rhs 
Traversable GuardedRhs 
Traversable Type 
Traversable Promoted 
Traversable TyVarBind 
Traversable Kind 
Traversable FunDep 
Traversable Context 
Traversable Asst 
Traversable Literal 
Traversable Sign 
Traversable Exp 
Traversable XName 
Traversable XAttr 
Traversable Bracket 
Traversable Splice 
Traversable Safety 
Traversable CallConv 
Traversable ModulePragma 
Traversable Overlap 
Traversable Activation 
Traversable Rule 
Traversable RuleVar 
Traversable WarningText 
Traversable Pat 
Traversable PXAttr 
Traversable RPatOp 
Traversable RPat 
Traversable PatField 
Traversable Stmt 
Traversable QualStmt 
Traversable FieldUpdate 
Traversable Alt 
Traversable Identity 
Traversable (Either a) 
Traversable ((,) a) 
Ix i => Traversable (Array i) 
Traversable (Const m) 
Traversable (Proxy *) 
Traversable (Map k) 
Traversable f => Traversable (ListT f) 
Traversable f => Traversable (MaybeT f) 
Traversable f => Traversable (IdentityT f) 
Traversable (HashMap k) 
Traversable f => Traversable (ErrorT e f) 
Traversable f => Traversable (WriterT w f) 
Traversable f => Traversable (WriterT w f) 
Traversable f => Traversable ((:&:) f a) 
(Traversable f, Traversable g) => Traversable ((:+:) f g) 
Traversable f => Traversable (Cxt h f) 

makeTraversable :: Name -> Q [Dec] Source

Derive an instance of Traversable for a type constructor of any first-order kind taking at least one argument.

HaskellStrict

makeHaskellStrict :: Name -> Q [Dec] Source

Derive an instance of HaskellStrict for a type constructor of any first-order kind taking at least one argument.

haskellStrict :: (Monad m, HaskellStrict f, f :<: g) => f (TermT m g) -> TermT m g Source

haskellStrict' :: (Monad m, HaskellStrict f, f :<: g) => f (TermT m g) -> TermT m g Source

Arbitrary

class ArbitraryF f where Source

Signature arbitration. An instance ArbitraryF f gives rise to an instance Arbitrary (Term f).

Minimal complete definition

Nothing

Methods

arbitraryF' :: Arbitrary v => [(Int, Gen (f v))] Source

arbitraryF :: Arbitrary v => Gen (f v) Source

shrinkF :: Arbitrary v => f v -> [f v] Source

Instances

ArbitraryF [] 
ArbitraryF Maybe 
Arbitrary b0 => ArbitraryF ((,) b) 
ArbitraryF f => ArbitraryF (Context f)

This lifts instances of ArbitraryF to instances of ArbitraryF for the corresponding context functor.

(Arbitrary b0, Arbitrary c0) => ArbitraryF ((,,) b c) 
(ArbitraryF f, Arbitrary p) => ArbitraryF ((:&:) f p) 
(ArbitraryF f, ArbitraryF g) => ArbitraryF ((:+:) f g)

Instances of ArbitraryF are closed under forming sums.

(Arbitrary b0, Arbitrary c0, Arbitrary d0) => ArbitraryF ((,,,) b c d) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0) => ArbitraryF ((,,,,) b c d e) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0, Arbitrary f0) => ArbitraryF ((,,,,,) b c d e f) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0, Arbitrary f0, Arbitrary g0) => ArbitraryF ((,,,,,,) b c d e f g) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0, Arbitrary f0, Arbitrary g0, Arbitrary h0) => ArbitraryF ((,,,,,,,) b c d e f g h) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0, Arbitrary f0, Arbitrary g0, Arbitrary h0, Arbitrary i0) => ArbitraryF ((,,,,,,,,) b c d e f g h i) 
(Arbitrary b0, Arbitrary c0, Arbitrary d0, Arbitrary e0, Arbitrary f0, Arbitrary g0, Arbitrary h0, Arbitrary i0, Arbitrary j0) => ArbitraryF ((,,,,,,,,,) b c d e f g h i j) 

makeArbitraryF :: Name -> Q [Dec] Source

Derive an instance of ArbitraryF for a type constructor of any first-order kind taking at least one argument. It is necessary that all types that are used by the data type definition are themselves instances of Arbitrary.

class Arbitrary a where

Random generation and shrinking of values.

Minimal complete definition

Nothing

Methods

arbitrary :: Gen a

A generator for values of the given type.

shrink :: a -> [a]

Produces a (possibly) empty list of all the possible immediate shrinks of the given value. The default implementation returns the empty list, so will not try to shrink the value.

Most implementations of shrink should try at least three things:

  1. Shrink a term to any of its immediate subterms.
  2. Recursively apply shrink to all immediate subterms.
  3. Type-specific shrinkings such as replacing a constructor by a simpler constructor.

For example, suppose we have the following implementation of binary trees:

data Tree a = Nil | Branch a (Tree a) (Tree a)

We can then define shrink as follows:

shrink Nil = []
shrink (Branch x l r) =
  -- shrink Branch to Nil
  [Nil] ++
  -- shrink to subterms
  [l, r] ++
  -- recursively shrink subterms
  [Branch x' l' r' | (x', l', r') <- shrink (x, l, r)]

There are a couple of subtleties here:

  • QuickCheck tries the shrinking candidates in the order they appear in the list, so we put more aggressive shrinking steps (such as replacing the whole tree by Nil) before smaller ones (such as recursively shrinking the subtrees).
  • It is tempting to write the last line as [Branch x' l' r' | x' <- shrink x, l' <- shrink l, r' <- shrink r] but this is the wrong thing! It will force QuickCheck to shrink x, l and r in tandem, and shrinking will stop once one of the three is fully shrunk.

There is a fair bit of boilerplate in the code above. We can avoid it with the help of some generic functions; note that these only work on GHC 7.2 and above. The function genericShrink tries shrinking a term to all of its subterms and, failing that, recursively shrinks the subterms. Using it, we can define shrink as:

shrink x = shrinkToNil x ++ genericShrink x
  where
    shrinkToNil Nil = []
    shrinkToNil (Branch _ l r) = [Nil]

genericShrink is a combination of subterms, which shrinks a term to any of its subterms, and recursivelyShrink, which shrinks all subterms of a term. These may be useful if you need a bit more control over shrinking than genericShrink gives you.

A final gotcha: we cannot define shrink as simply shrink x = Nil:genericShrink x as this shrinks Nil to Nil, and shrinking will go into an infinite loop.

If all this leaves you bewildered, you might try shrink = genericShrink to begin with, after deriving Generic and Typeable for your type. However, if your data type has any special invariants, you will need to check that genericShrink can't break those invariants.

Instances

Arbitrary Bool 
Arbitrary Char 
Arbitrary Double 
Arbitrary Float 
Arbitrary Int 
Arbitrary Int8 
Arbitrary Int16 
Arbitrary Int32 
Arbitrary Int64 
Arbitrary Integer 
Arbitrary Ordering 
Arbitrary Word 
Arbitrary Word8 
Arbitrary Word16 
Arbitrary Word32 
Arbitrary Word64 
Arbitrary () 
Arbitrary a => Arbitrary [a] 
(Integral a, Arbitrary a) => Arbitrary (Ratio a) 
HasResolution a => Arbitrary (Fixed a) 
(RealFloat a, Arbitrary a) => Arbitrary (Complex a) 
Arbitrary a => Arbitrary (Maybe a) 
ArbitraryF f => Arbitrary (Term f)

This lifts instances of ArbitraryF to instances of Arbitrary for the corresponding term type.

(CoArbitrary a, Arbitrary b) => Arbitrary (a -> b) 
(Arbitrary a, Arbitrary b) => Arbitrary (Either a b) 
(Arbitrary a, Arbitrary b) => Arbitrary (a, b) 
(ArbitraryF f, Arbitrary a) => Arbitrary (Context f a)

This lifts instances of ArbitraryF to instances of Arbitrary for the corresponding context type.

(Arbitrary a, Arbitrary b, Arbitrary c) => Arbitrary (a, b, c) 
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => Arbitrary (a, b, c, d) 
(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e) => Arbitrary (a, b, c, d, e) 

makeArbitrary :: Name -> Q [Dec] Source

Derive an instance of Arbitrary for a type constructor.

class NFData a where

A class of types that can be fully evaluated.

Since: 1.1.0.0

Minimal complete definition

Nothing

Methods

rnf :: a -> ()

rnf should reduce its argument to normal form (that is, fully evaluate all sub-components), and then return '()'.

The default implementation of rnf is

rnf a = a `seq` ()

which may be convenient when defining instances for data types with no unevaluated fields (e.g. enumerations).

Instances

NFData Bool 
NFData Char 
NFData Double 
NFData Float 
NFData Int 
NFData Int8 
NFData Int16 
NFData Int32 
NFData Int64 
NFData Integer 
NFData Word 
NFData Word8 
NFData Word16 
NFData Word32 
NFData Word64 
NFData () 
NFData Version

Since: 1.3.0.0

NFData Text 
NFData Text 
NFData LocalTime 
NFData ZonedTime 
NFData UTCTime 
NFData NominalDiffTime 
NFData Day 
NFData a => NFData [a] 
(Integral a, NFData a) => NFData (Ratio a) 
NFData (Fixed a)

Since: 1.3.0.0

(RealFloat a, NFData a) => NFData (Complex a) 
NFData a => NFData (Maybe a) 
NFData a => NFData (Set a) 
NFData a => NFData (Tree a) 
NFData a => NFData (HashSet a) 
NFData (a -> b)

This instance is for convenience and consistency with seq. This assumes that WHNF is equivalent to NF for functions.

Since: 1.3.0.0

(NFData a, NFData b) => NFData (Either a b) 
(NFData a, NFData b) => NFData (a, b) 
(Ix a, NFData a, NFData b) => NFData (Array a b) 
(NFData k, NFData a) => NFData (Map k a) 
(NFData k, NFData v) => NFData (Leaf k v) 
(NFData k, NFData v) => NFData (HashMap k v) 
(NFData a, NFData b, NFData c) => NFData (a, b, c) 
(NFDataF f, NFData a) => NFData (Cxt h f a) 
(NFData a, NFData b, NFData c, NFData d) => NFData (a, b, c, d) 
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5) => NFData (a1, a2, a3, a4, a5) 
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6) => NFData (a1, a2, a3, a4, a5, a6) 
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) => NFData (a1, a2, a3, a4, a5, a6, a7) 
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8) => NFData (a1, a2, a3, a4, a5, a6, a7, a8) 
(NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7, NFData a8, NFData a9) => NFData (a1, a2, a3, a4, a5, a6, a7, a8, a9) 

makeNFData :: Name -> Q [Dec] Source

Derive an instance of NFData for a type constructor.

DeepSeq

class NFDataF f where Source

Signature normal form. An instance NFDataF f gives rise to an instance NFData (Term f).

Methods

rnfF :: NFData a => f a -> () Source

Instances

NFDataF [] 
NFDataF Maybe 
NFData a0 => NFDataF ((,) a) 
(NFDataF f, NFData a) => NFDataF ((:&:) f a) 
(NFDataF f, NFDataF g) => NFDataF ((:+:) f g) 

makeNFDataF :: Name -> Q [Dec] Source

Derive an instance of NFDataF for a type constructor of any first-order kind taking at least one argument.

Smart Constructors

smartConstructors :: Name -> Q [Dec] Source

Derive smart constructors for a type constructor of any first-order kind taking at least one argument. The smart constructors are similar to the ordinary constructors, but an inject is automatically inserted.

Smart Constructors w/ Annotations

smartAConstructors :: Name -> Q [Dec] Source

Derive smart constructors with products for a type constructor of any parametric kind taking at least one argument. The smart constructors are similar to the ordinary constructors, but an injectA is automatically inserted.

Lifting to Sums

liftSum :: Name -> Q [Dec] Source

Given the name of a type class, where the first parameter is a functor, lift it to sums of functors. Example: class ShowF f where ... is lifted as instance (ShowF f, ShowF g) => ShowF (f :+: g) where ... .