-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Generic programming library for generalised deriving.
--
-- This package provides functionality for generalising the deriving
-- mechanism in Haskell to arbitrary classes. It was first described in
-- the paper:
--
--
-- - A generic deriving mechanism for Haskell. Jose Pedro
-- Magalhaes, Atze Dijkstra, Johan Jeuring, and Andres Loeh.
-- Haskell'10.
--
--
-- The current implementation integrates with the new GHC Generics. See
-- http://www.haskell.org/haskellwiki/GHC.Generics for more
-- information. Template Haskell code is provided for supporting GHC
-- before version 7.2.
@package generic-deriving
@version 1.6
module Generics.Deriving.Instances
module Generics.Deriving.Base
module Generics.Deriving.Copoint
class GCopoint d where gcopoint = gcopointdefault
gcopoint :: GCopoint d => d a -> a
gcopointdefault :: (Generic1 d, GCopoint' (Rep1 d)) => d a -> a
instance (GCopoint f, GCopoint' g) => GCopoint' (f :.: g)
instance GCopoint f => GCopoint' (Rec1 f)
instance (GCopoint' f, GCopoint' g) => GCopoint' (f :*: g)
instance (GCopoint' f, GCopoint' g) => GCopoint' (f :+: g)
instance GCopoint' f => GCopoint' (M1 i c f)
instance GCopoint' (K1 i c)
instance GCopoint' Par1
instance GCopoint' U1
-- | Summary: Return the name of all the constructors of a type.
module Generics.Deriving.ConNames
class ConNames f
gconNames :: ConNames f => f a -> [String]
-- | Return the name of all the constructors of the type of the given term.
conNames :: (Generic a, ConNames (Rep a)) => a -> [String]
instance Constructor c => ConNames (C1 c f)
instance ConNames f => ConNames (D1 c f)
instance (ConNames f, ConNames g) => ConNames (f :+: g)
module Generics.Deriving.Eq
class GEq a where geq x y = geq' (from x) (from y)
geq :: GEq a => a -> a -> Bool
instance GEq a => GEq [a]
instance GEq a => GEq (Maybe a)
instance GEq Float
instance GEq Int
instance GEq Char
instance (GEq' a, GEq' b) => GEq' (a :*: b)
instance (GEq' a, GEq' b) => GEq' (a :+: b)
instance GEq' a => GEq' (M1 i c a)
instance GEq c => GEq' (K1 i c)
instance GEq' U1
module Generics.Deriving.Enum
class GEnum a where genum = genumDefault
genum :: GEnum a => [a]
genumDefault :: (Generic a, Enum' (Rep a)) => [a]
toEnumDefault :: (Generic a, Enum' (Rep a)) => Int -> a
fromEnumDefault :: (GEq a, Generic a, Enum' (Rep a)) => a -> Int
class Ord a => GIx a where range = rangeDefault index = indexDefault inRange = inRangeDefault
range :: GIx a => (a, a) -> [a]
index :: GIx a => (a, a) -> a -> Int
inRange :: GIx a => (a, a) -> a -> Bool
rangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> [a]
indexDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Int
inRangeDefault :: (GEq a, Generic a, Enum' (Rep a)) => (a, a) -> a -> Bool
instance GIx Int
instance (GEq a, GEnum a, GIx a) => GIx [a]
instance (GEq a, GEnum a, GIx a) => GIx (Maybe a)
instance GEnum Int
instance GEnum a => GEnum [a]
instance GEnum a => GEnum (Maybe a)
instance (Enum' f, Enum' g) => Enum' (f :*: g)
instance (Enum' f, Enum' g) => Enum' (f :+: g)
instance Enum' f => Enum' (M1 i c f)
instance GEnum c => Enum' (K1 i c)
instance Enum' U1
module Generics.Deriving.Functor
class GFunctor f where gmap = gmapdefault
gmap :: GFunctor f => (a -> b) -> f a -> f b
gmapdefault :: (Generic1 f, GFunctor' (Rep1 f)) => (a -> b) -> f a -> f b
instance GFunctor []
instance GFunctor Maybe
instance (GFunctor f, GFunctor' g) => GFunctor' (f :.: g)
instance (GFunctor' f, GFunctor' g) => GFunctor' (f :*: g)
instance (GFunctor' f, GFunctor' g) => GFunctor' (f :+: g)
instance GFunctor' f => GFunctor' (M1 i c f)
instance GFunctor f => GFunctor' (Rec1 f)
instance GFunctor' (K1 i c)
instance GFunctor' Par1
instance GFunctor' U1
module Generics.Deriving.Show
class GShow a where gshows = gshowsPrec 0 gshow x = gshows x "" gshowsPrec = gshowsPrecdefault
gshowsPrec :: GShow a => Int -> a -> ShowS
gshows :: GShow a => a -> ShowS
gshow :: GShow a => a -> String
gshowsPrecdefault :: (Generic a, GShow' (Rep a)) => Int -> a -> ShowS
instance [overlap ok] GShow a => GShow [a]
instance [overlap ok] GShow Bool
instance [overlap ok] GShow String
instance [overlap ok] GShow Float
instance [overlap ok] GShow Int
instance [overlap ok] GShow Char
instance [overlap ok] GShow a => GShow (Maybe a)
instance [overlap ok] (GShow' a, GShow' b) => GShow' (a :*: b)
instance [overlap ok] (GShow' a, GShow' b) => GShow' (a :+: b)
instance [overlap ok] GShow' a => GShow' (M1 D d a)
instance [overlap ok] (Selector s, GShow' a) => GShow' (M1 S s a)
instance [overlap ok] (GShow' a, Constructor c) => GShow' (M1 C c a)
instance [overlap ok] GShow c => GShow' (K1 i c)
instance [overlap ok] GShow' U1
-- | Summary: Functions inspired by the Uniplate generic programming
-- library, mostly implemented by Sean Leather.
module Generics.Deriving.Uniplate
class Uniplate a where children = childrendefault context = contextdefault descend = descenddefault descendM = descendMdefault transform = transformdefault transformM = transformMdefault
children :: Uniplate a => a -> [a]
context :: Uniplate a => a -> [a] -> a
descend :: Uniplate a => (a -> a) -> a -> a
descendM :: (Uniplate a, Monad m) => (a -> m a) -> a -> m a
transform :: Uniplate a => (a -> a) -> a -> a
transformM :: (Uniplate a, Monad m) => (a -> m a) -> a -> m a
uniplate :: Uniplate a => a -> ([a], [a] -> a)
universe :: Uniplate a => a -> [a]
rewrite :: Uniplate a => (a -> Maybe a) -> a -> a
rewriteM :: (Monad m, Uniplate a) => (a -> m (Maybe a)) -> a -> m a
contexts :: Uniplate a => a -> [(a, a -> a)]
holes :: Uniplate a => a -> [(a, a -> a)]
para :: Uniplate a => (a -> [r] -> r) -> a -> r
childrendefault :: (Generic a, Uniplate' (Rep a) a) => a -> [a]
contextdefault :: (Generic a, Context' (Rep a) a) => a -> [a] -> a
descenddefault :: (Generic a, Uniplate' (Rep a) a) => (a -> a) -> a -> a
descendMdefault :: (Generic a, Uniplate' (Rep a) a, Monad m) => (a -> m a) -> a -> m a
transformdefault :: (Generic a, Uniplate' (Rep a) a) => (a -> a) -> a -> a
transformMdefault :: (Generic a, Uniplate' (Rep a) a, Monad m) => (a -> m a) -> a -> m a
instance [overlap ok] Uniplate [a]
instance [overlap ok] Uniplate (Either a b)
instance [overlap ok] Uniplate (Maybe a)
instance [overlap ok] Uniplate (b, c, d, e, f, g, h)
instance [overlap ok] Uniplate (b, c, d, e, f, g)
instance [overlap ok] Uniplate (b, c, d, e, f)
instance [overlap ok] Uniplate (b, c, d, e)
instance [overlap ok] Uniplate (b, c, d)
instance [overlap ok] Uniplate (b, c)
instance [overlap ok] Uniplate ()
instance [overlap ok] Uniplate Int
instance [overlap ok] Uniplate Float
instance [overlap ok] Uniplate Double
instance [overlap ok] Uniplate Char
instance [overlap ok] Uniplate Bool
instance [overlap ok] Context' g b => Context' (f :*: g) b
instance [overlap ok] Context' g a => Context' (M1 i c (K1 j a) :*: g) a
instance [overlap ok] (Context' f b, Context' g b) => Context' (f :+: g) b
instance [overlap ok] Context' f b => Context' (M1 i c f) b
instance [overlap ok] Context' (K1 i a) b
instance [overlap ok] Context' (K1 i a) a
instance [overlap ok] Context' U1 b
instance [overlap ok] (Uniplate' f b, Uniplate' g b) => Uniplate' (f :*: g) b
instance [overlap ok] (Uniplate' f b, Uniplate' g b) => Uniplate' (f :+: g) b
instance [overlap ok] Uniplate' f b => Uniplate' (M1 i c f) b
instance [overlap ok] Uniplate' (K1 i a) b
instance [overlap ok] Uniplate a => Uniplate' (K1 i a) a
instance [overlap ok] Uniplate' U1 a
module Generics.Deriving.Foldable
class GFoldable t where gfoldMap = gfoldMapdefault gfold = gfoldMap id gfoldr f z t = appEndo (gfoldMap (Endo . f) t) z gfoldr' f z0 xs = gfoldl f' id xs z0 where f' k x z = k $! f x z gfoldl f z t = appEndo (getDual (gfoldMap (Dual . Endo . flip f) t)) z gfoldl' f z0 xs = gfoldr f' id xs z0 where f' x k z = k $! f z x gfoldr1 f xs = fromMaybe (error "gfoldr1: empty structure") (gfoldr mf Nothing xs) where mf x Nothing = Just x mf x (Just y) = Just (f x y) gfoldl1 f xs = fromMaybe (error "foldl1: empty structure") (gfoldl mf Nothing xs) where mf Nothing y = Just y mf (Just x) y = Just (f x y)
gfoldMap :: (GFoldable t, Monoid m) => (a -> m) -> t a -> m
gfold :: (GFoldable t, Monoid m) => t m -> m
gfoldr :: GFoldable t => (a -> b -> b) -> b -> t a -> b
gfoldr' :: GFoldable t => (a -> b -> b) -> b -> t a -> b
gfoldl :: GFoldable t => (a -> b -> a) -> a -> t b -> a
gfoldl' :: GFoldable t => (a -> b -> a) -> a -> t b -> a
gfoldr1 :: GFoldable t => (a -> a -> a) -> t a -> a
gfoldl1 :: GFoldable t => (a -> a -> a) -> t a -> a
gfoldMapdefault :: (Generic1 t, GFoldable' (Rep1 t), Monoid m) => (a -> m) -> t a -> m
gtoList :: GFoldable t => t a -> [a]
gconcat :: GFoldable t => t [a] -> [a]
gconcatMap :: GFoldable t => (a -> [b]) -> t a -> [b]
gand :: GFoldable t => t Bool -> Bool
gor :: GFoldable t => t Bool -> Bool
gany :: GFoldable t => (a -> Bool) -> t a -> Bool
gall :: GFoldable t => (a -> Bool) -> t a -> Bool
gsum :: (GFoldable t, Num a) => t a -> a
gproduct :: (GFoldable t, Num a) => t a -> a
gmaximum :: (GFoldable t, Ord a) => t a -> a
gmaximumBy :: GFoldable t => (a -> a -> Ordering) -> t a -> a
gminimum :: (GFoldable t, Ord a) => t a -> a
gminimumBy :: GFoldable t => (a -> a -> Ordering) -> t a -> a
gelem :: (GFoldable t, Eq a) => a -> t a -> Bool
gnotElem :: (GFoldable t, Eq a) => a -> t a -> Bool
gfind :: GFoldable t => (a -> Bool) -> t a -> Maybe a
instance GFoldable []
instance GFoldable Maybe
instance (GFoldable f, GFoldable' g) => GFoldable' (f :.: g)
instance (GFoldable' f, GFoldable' g) => GFoldable' (f :*: g)
instance (GFoldable' f, GFoldable' g) => GFoldable' (f :+: g)
instance GFoldable' f => GFoldable' (M1 i c f)
instance GFoldable f => GFoldable' (Rec1 f)
instance GFoldable' (K1 i c)
instance GFoldable' Par1
instance GFoldable' U1
-- | This module provides two main features:
--
--
-- - GMonoid, a generic version of the Monoid type class,
-- including instances of the types from Data.Monoid
-- - Default generic definitions for the Monoid methods
-- mempty and mappend
--
--
-- The generic defaults only work for types without alternatives (i.e.
-- they have only one constructor). We cannot in general know how to deal
-- with different constructors.
module Generics.Deriving.Monoid
class GMonoid a where gmconcat = foldr gmappend gmempty gmempty = to gmempty' gmappend x y = to (gmappend' (from x) (from y))
gmempty :: GMonoid a => a
gmappend :: GMonoid a => a -> a -> a
gmconcat :: GMonoid a => [a] -> a
gmemptydefault :: (Generic a, GMonoid' (Rep a)) => a
gmappenddefault :: (Generic a, GMonoid' (Rep a)) => a -> a -> a
memptydefault :: (Generic a, Monoid' (Rep a)) => a
mappenddefault :: (Generic a, Monoid' (Rep a)) => a -> a -> a
instance (GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f, GMonoid g, GMonoid h) => GMonoid (a, b, c, d, e, f, g, h)
instance (GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f, GMonoid g) => GMonoid (a, b, c, d, e, f, g)
instance (GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e, GMonoid f) => GMonoid (a, b, c, d, e, f)
instance (GMonoid a, GMonoid b, GMonoid c, GMonoid d, GMonoid e) => GMonoid (a, b, c, d, e)
instance (GMonoid a, GMonoid b, GMonoid c, GMonoid d) => GMonoid (a, b, c, d)
instance (GMonoid a, GMonoid b, GMonoid c) => GMonoid (a, b, c)
instance (GMonoid a, GMonoid b) => GMonoid (a, b)
instance GMonoid b => GMonoid (a -> b)
instance GMonoid a => GMonoid (Maybe a)
instance GMonoid a => GMonoid (Dual a)
instance GMonoid (Endo a)
instance GMonoid [a]
instance Num a => GMonoid (Product a)
instance Num a => GMonoid (Sum a)
instance GMonoid (Last a)
instance GMonoid (First a)
instance GMonoid All
instance GMonoid Any
instance GMonoid ()
instance GMonoid Ordering
instance (Monoid' f, Monoid' h) => Monoid' (f :*: h)
instance Monoid' f => Monoid' (M1 i c f)
instance Monoid a => Monoid' (K1 i a)
instance Monoid' U1
instance (GMonoid' f, GMonoid' h) => GMonoid' (f :*: h)
instance GMonoid' f => GMonoid' (M1 i c f)
instance GMonoid a => GMonoid' (K1 i a)
instance GMonoid' U1
module Generics.Deriving.Traversable
class (GFunctor t, GFoldable t) => GTraversable t where gtraverse = gtraversedefault gsequenceA = gtraverse id gmapM f = unwrapMonad . gtraverse (WrapMonad . f) gsequence = gmapM id
gtraverse :: (GTraversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
gsequenceA :: (GTraversable t, Applicative f) => t (f a) -> f (t a)
gmapM :: (GTraversable t, Monad m) => (a -> m b) -> t a -> m (t b)
gsequence :: (GTraversable t, Monad m) => t (m a) -> m (t a)
gtraversedefault :: (Generic1 t, GTraversable' (Rep1 t), Applicative f) => (a -> f b) -> t a -> f (t b)
instance GTraversable []
instance GTraversable Maybe
instance (GTraversable f, GTraversable' g) => GTraversable' (f :.: g)
instance (GTraversable' f, GTraversable' g) => GTraversable' (f :*: g)
instance (GTraversable' f, GTraversable' g) => GTraversable' (f :+: g)
instance GTraversable' f => GTraversable' (M1 i c f)
instance GTraversable f => GTraversable' (Rec1 f)
instance GTraversable' (K1 i c)
instance GTraversable' Par1
instance GTraversable' U1
-- | This module contains Template Haskell code that can be used to
-- automatically generate the boilerplate code for the generic deriving
-- library. For now, it generates only the Generic instance. Empty
-- datatypes are not yet supported.
module Generics.Deriving.TH
-- | Given the type and the name (as string) for the type to derive,
-- generate the Data instance, the Constructor instances,
-- and the Selector instances.
deriveMeta :: Name -> Q [Dec]
-- | Given a datatype name, derive a datatype and instance of class
-- Datatype.
deriveData :: Name -> Q [Dec]
-- | Given a datatype name, derive datatypes and instances of class
-- Constructor.
deriveConstructors :: Name -> Q [Dec]
-- | Given a datatype name, derive datatypes and instances of class
-- Selector.
deriveSelectors :: Name -> Q [Dec]
instance Lift Associativity
instance Lift Fixity
module Generics.Deriving