-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A program and library to derive instances for data types -- -- 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 -- DrIFT. @package derive @version 0.1.3 module Language.Haskell.TH.SYB module Language.Haskell.TH.FixedPpr nestDepth :: Int type Precedence = Int opPrec :: Precedence noPrec :: Precedence appPrec :: Precedence parensIf :: Bool -> Doc -> Doc showNameRaw :: Name -> String isPrefixName :: Name -> Bool pprName_ :: Bool -> Name -> Doc pprint :: (Ppr a) => a -> String class Ppr a ppr :: (Ppr a) => a -> Doc ppr_list :: (Ppr a) => [a] -> Doc pprFixity :: Name -> Fixity -> Doc pprExpInfix :: Exp -> Doc pprExp :: Precedence -> Exp -> Doc pprFields :: [(Name, Exp)] -> Doc pprMaybeExp :: Precedence -> Maybe Exp -> Doc pprBody :: Bool -> Body -> Doc pprLit :: Precedence -> Lit -> Doc pprPat :: Precedence -> Pat -> Doc pprVarStrictType :: (Name, Strict, Type) -> Doc pprStrictType :: (Strict, Type) -> Doc pprParendType :: Type -> Doc pprTyApp :: (Type, [Type]) -> Doc split :: Type -> (Type, [Type]) pprCxt :: Cxt -> Doc where_clause :: [Dec] -> Doc showtextl :: (Show a) => a -> Doc instance Ppr Range instance Ppr Type instance Ppr Con instance Ppr Clause instance Ppr Foreign instance Ppr FunDep instance Ppr Dec instance Ppr Pat instance Ppr Lit instance Ppr Body instance Ppr Match instance Ppr Stmt instance Ppr Exp instance Ppr Info instance Ppr Name instance (Ppr a) => Ppr [a] -- | The core module of the Data.Derive system. This module contains the -- data types used for communication between the extractors and the -- derivors. module Language.Haskell.TH.Data type DataDef = Dec type CtorDef = Con dataName :: DataDef -> String qualifiedDataName :: DataDef -> Name dataArity :: DataDef -> Int dataCtors :: DataDef -> [CtorDef] ctorName :: CtorDef -> String qualifiedCtorName :: CtorDef -> Name ctorArity :: CtorDef -> Int ctorStrictTypes :: CtorDef -> [StrictType] ctorTypes :: CtorDef -> [Type] ctorFields :: CtorDef -> [String] dropModule :: String -> String normData :: DataDef -> DataDef unqualifiedName :: Name -> Name typeApp :: Type -> (Type, [Type]) eqConT :: String -> Type -> Bool isTupleT :: Type -> Bool ex_args :: DataDef -> [Name] -- | Expand type synonyms in data declarations. -- -- This is needed for some type based derivations. module Language.Haskell.TH.ExpandSynonym -- | Expand type synonyms in a data declaration expandData :: DataDef -> Q DataDef -- | These small short-named functions are intended to make the -- construction of abstranct syntax trees less tedious. module Language.Haskell.TH.Helper foldl1With :: Exp -> [Exp] -> Exp foldr1With :: Exp -> [Exp] -> Exp applyWith :: Exp -> [Exp] -> Exp -- | A simple clause, without where or guards. sclause :: [Pat] -> Exp -> Clause -- | A default clause with N arguments. defclause :: Int -> Exp -> Clause -- | A simple Val clause sval :: Pat -> Exp -> Dec case' :: Exp -> [(Pat, Exp)] -> Exp (->:) :: String -> Exp -> Exp -- | We provide 3 standard instance constructors instance_default requires -- C for each free type variable instance_none requires no context -- instance_context requires a given context instance_none :: String -> DataDef -> [Dec] -> Dec instance_default :: String -> DataDef -> [Dec] -> Dec instance_context :: [String] -> String -> DataDef -> [Dec] -> Dec -- | Build an instance of a class for a data type, using the heuristic that -- the type is itself required on all type arguments. simple_instance :: String -> DataDef -> [Dec] -> [Dec] -- | Build an instance of a class for a data type, using the class at the -- given types generic_instance :: String -> DataDef -> [Type] -> [Dec] -> [Dec] -- | Build a fundecl with a string name funN :: String -> [Clause] -> Dec -- | The class used to overload lifting operations. To reduce code -- duplication, we overload the wrapped constructors (and everything -- else, but that's irrelevant) to work in patterns, expressions, and -- types. class Valcon a lK :: (Valcon a) => String -> [a] -> a vr :: (Valcon a) => String -> a raw_lit :: (Valcon a) => Lit -> a tup :: (Valcon a) => [a] -> a lst :: (Valcon a) => [a] -> a -- | Build an application node without a given head app :: Exp -> [Exp] -> Exp -- | This class is used to overload literal construction based on the type -- of the literal. class LitC a lit :: (LitC a, Valcon p) => a -> p dataVars :: DataDef -> [Type] -- | Common pattern: list of a familiy of variables vars :: (Valcon a) => Char -> Int -> [a] -- | Variable based on a letter + number vrn :: (Valcon a) => Char -> Int -> a -- | Make a list of variables, one for each argument to a constructor ctv :: (Valcon a) => CtorDef -> Char -> [a] -- | Make a simple pattern to bind a constructor ctp :: (Valcon a) => CtorDef -> Char -> a -- | Reference the constructor itself ctc :: (Valcon a) => CtorDef -> a l0 :: (Valcon a) => String -> a l1 :: (Valcon a) => String -> a -> a l2 :: (Valcon a) => String -> a -> a -> a false :: (Valcon a) => a nil :: (Valcon a) => a true :: (Valcon a) => a hZero' :: Type hNil' :: Type cons :: (Valcon a) => a -> a -> a box :: (Valcon a) => a -> a const' :: Exp -> Exp return' :: Exp -> Exp hSucc' :: Type -> Type (&&:) :: Exp -> Exp -> Exp (++:) :: Exp -> Exp -> Exp (>>=:) :: Exp -> Exp -> Exp (>>:) :: Exp -> Exp -> Exp (.:) :: Exp -> Exp -> Exp ap' :: Exp -> Exp -> Exp (>:) :: Exp -> Exp -> Exp (==:) :: Exp -> Exp -> Exp hCons' :: Type -> Type -> Type -- | Build a chain of expressions, with an appropriate terminal sequence__ -- does not require a unit at the end (all others are optimised -- automatically) (++::) :: [Exp] -> Exp (>>::) :: [Exp] -> Exp sequence__ :: [Exp] -> Exp (.::) :: [Exp] -> Exp (&&::) :: [Exp] -> Exp -- | K-way liftM liftmk :: Exp -> [Exp] -> Exp instance LitC () instance (LitC a, LitC b, LitC c) => LitC (a, b, c) instance (LitC a, LitC b) => LitC (a, b) instance (LitC a) => LitC [a] instance LitC Char instance LitC Integer instance Valcon Type instance Valcon Pat instance Valcon Exp module Language.Haskell.TH.Peephole peephole :: (Data a) => a -> a replaceVar :: Name -> Exp -> Exp -> Exp replaceVars :: [(Name, Exp)] -> Exp -> Exp module Language.Haskell.TH.All -- | The type of ways to derive classes. Should not really be in this -- module! data Derivation Derivation :: (DataDef -> Q [Dec]) -> String -> Derivation -- | The derivation function proper derivationDeriver :: Derivation -> DataDef -> Q [Dec] -- | The name of the derivation derivationName :: Derivation -> String derivation :: (DataDef -> [Dec]) -> String -> Derivation derivationQ :: (DataDef -> Q [Dec]) -> String -> Derivation -- | Derive Play, implemented for tuples and lists. module Data.Derive.Uniplate makeUniplate :: Derivation instance Eq Container instance Show Container -- | Derivation for the Typeable class, as described in the Scrap Your -- Boilerplate papers. This derivation generates instances for all kinds -- of TypeableK classes; as such we do NOT require the GHC-specific -- generic downkinding instances to provide lower kind instances. -- -- The generated TypeRep uses only the base name of the type, so -- identically named types in different modules can be treated as the -- same, with disasterous consequences. -- -- Also creates a typename_<the type name> value to hold -- the TypeRep. module Data.Derive.Typeable makeTypeable :: Derivation -- | Type level typeable, as used by the undecidable-instances version of -- the TypeEq class from Oleg and Lammel's HList library. The -- type numbers used are autmatically generated using a little-endian -- Enum representation of the type's name. Note that we truncate -- characters above 255, and ignore the module name, though the -- consequences are much less severe than in the Typeable case -- since no coercion is involved. module Data.Derive.TTypeable makeTTypeable :: Derivation -- | Derives Show. This is as defined by the Haskell report, -- except there is no support for infix constructors. If you attempt to -- derive Show for a data type with infix constructors, the -- constructors are handled as if they were prefix constructors, using -- the (consym) syntax. module Data.Derive.Show makeShow :: Derivation -- | A pseudo derivation. For each field in the data type, deriving -- Set generates setFieldName v x = -- x{fieldName = v}. This derivation is intended to -- work around the fact that in Haskell assigning to a field is not a -- first class object (although extracting from a field is). module Data.Derive.Set makeSet :: Derivation -- | Derivation for the Serial class used by SmallCheck. Following -- the guidelines in the SmallCheck README -- http://www.cs.york.ac.uk/fp/darcs/smallcheck/README, we -- implement both series and coseries. The generated -- instances use the SmallCheck instance combinators in the proscribed -- way. module Data.Derive.Serial makeSerial :: Derivation -- | A pseudo derivation. For each field in the data type, deriving -- Ref generates refFieldName = Ref { select -- = fieldName , update = f v -> v { -- fieldName = f (fieldName v) } }. -- -- This is intended for use with the compositional functional references -- described in -- http://www.haskell.org/pipermail/haskell-cafe/2007-June/026477.html. module Data.Derive.Ref makeRef :: Derivation -- | Derives Read. This is as defined by the Haskell report, -- except there is no support for infix constructors. If you attempt to -- derive Read for a data type with infix constructors, the -- constructors are handled as if they were prefix constructors, using -- the (consym) syntax. module Data.Derive.Read makeRead :: Derivation module Data.Derive.PlateTypeable makePlateTypeable :: Derivation -- | Derive Play, implemented for tuples and lists. module Data.Derive.PlateDirect makePlateDirect :: Derivation -- | Derive Ord, as specified in the Haskell 98 Language Report. module Data.Derive.Ord makeOrd :: Derivation -- | Derive NFData, from Control.Parallel.Strategies. module Data.Derive.NFData makeNFData :: Derivation -- | Derives an instance of Monoid. This derivation is limited to -- data types with only one constructor; it uses the product construction -- of monoids. module Data.Derive.Monoid makeMonoid :: Derivation -- | A pseudo derivation. For each field in the data type, deriving -- LazySet generates a function like a record updator, but lazy. -- This is very useful in certain situations to improve laziness -- properties. Example: -- --
-- data Foo = Foo { x :: Int, y :: Int, z :: Int }
--
--
-- becomes:
--
-- -- setX v f = Foo v (y f) (z f) -- setY v f = Foo (x f) v (z f) -- setZ v f = Foo (x f) (y f) v --module Data.Derive.LazySet makeLazySet :: Derivation -- | A pseudo derivation. For each constructor of the data type, -- Is generates isCtorName which returns -- True if given an object build using the appropriate -- constructor, and False otherwise. module Data.Derive.Is makeIs :: Derivation -- | Has is a pseudo derivation. For each field of any constructor of the -- data type, Has generates hasFieldName which returns -- True if given the the given field is a member of the -- constructor of the passed object, and False otherwise. module Data.Derive.Has makeHas :: Derivation -- | A pseudo derivation. For each constructor in the data type, deriving -- From generates fromCtorName which extracts -- the components if given the appropriate constructor, and crashes -- otherwise. Unlike the DrIFT "From" derivation, our version -- works for all constructors - zero-arity constructors always return -- (), arity-one constructors return the contained value, and -- all others return a tuple with all the components. module Data.Derive.From makeFrom :: Derivation -- | Derive Eq, as specified in the Haskell 98 Language Report. module Data.Derive.Eq makeEq :: Derivation -- | EnumCyclic defines the Enum class, using the same -- modifications as our Enum derivation, but additionally -- succ and pred treat the data type as cyclic, -- wrapping between the first and last constructors. module Data.Derive.EnumCyclic makeEnumCyclic :: Derivation -- | Derivation for Enum, as defined by the Haskell 98 Language -- report, except that we support arbitrary types. toEnum (and derived -- functions, notably succ and pred) use undefined to fill all fields of -- nonzero arity constructors. module Data.Derive.Enum makeEnum :: Derivation -- | Derivation for the Data.Generics.Basics.Data class, as described in -- the Scrap Your Boilerplate paper. No type structure is abstracted module Data.Derive.Data makeData :: Derivation -- | Derive Bounded, as specified in the Haskell 98 Language -- Report. As an extension, we support deriving Bounded for all -- data types. If the first or last constructor has non-zero arity, we -- call minBound (respectively, maxBound) recursively to fill in the -- fields. module Data.Derive.Bounded makeBounded :: Derivation -- | Derivation for Data.Binary's Binary class for serializing values. The -- generated instances implement a very simple tagged data format. module Data.Derive.BinaryOld makeBinaryOld :: Derivation -- | Derivation for Neil Mitchell's BinaryDefer class. XXX: do research, -- write useful haddock module Data.Derive.BinaryDefer makeBinaryDefer :: Derivation -- | Derivation for Data.Binary's Binary class for serializing values. The -- generated instances implement a very simple tagged data format. First, -- the (0-based) constructor number is stored, in the smallest of 0, 1, -- 2, or 4 bytes that can represent the entire range. Then, the -- constructor's arguments are stored, in order, using the Binary -- instances in scope. module Data.Derive.Binary makeBinary :: Derivation -- | Derivation for Test.QuickCheck.Arbitrary (version 2 of quickcheck.) -- --
-- data Foo = Foo ; $( derive makeEq ''Foo ) --module Data.DeriveTH -- | Derive an instance of some class. derive only derives -- instances for the type of the argument. derive :: Derivation -> Name -> Q [Dec] -- | The type of ways to derive classes. Should not really be in this -- module! data Derivation -- | Derive for a type and print the code to standard output. This is a -- internal hook for the use of the Derive executable. _derive_string_instance :: Derivation -> Name -> Q Exp module Data.DeriveGuess data DataName a CtorZero :: DataName a CtorOne :: a -> DataName a CtorTwo :: a -> a -> DataName a CtorTwo' :: a -> a -> DataName a -- | Guess an instantiator from a sample instance. guess :: (String, Q [Dec]) -> IO () instance Show Env instance Eq Env instance Guess Lit instance Guess Match instance Guess Exp instance Guess Body instance Guess Pat instance Guess Stmt instance Guess Clause instance Guess Name instance Guess Dec instance (Guess a) => Guess [a]