-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generic programming library with representation types -- -- Generic programming library providing structural polymorphism and -- other features. @package RepLib @version 0.5.3.1 -- | Basic data structure and class for representation types module Generics.RepLib.R -- | A value of type R a is a representation of a type a. data R a Int :: R Int Char :: R Char Integer :: R Integer Float :: R Float Double :: R Double Rational :: R Rational IOError :: R IOError IO :: R a -> R (IO a) Arrow :: R a -> R b -> R (a -> b) Data :: DT -> [Con R a] -> R a Abstract :: DT -> R a Equal :: R a -> R b -> R (a :=: b) -- | Representation of a data constructor includes an embedding between the -- datatype and a list of other types as well as the representation of -- that list of other types. data Con r a Con :: Emb l a -> MTup r l -> Con r a -- | An embedding between a list of types l and a datatype -- a, based on a particular data constructor. The to function is -- a wrapper for the constructor, the from function pattern matches on -- the constructor. data Emb l a Emb :: (l -> a) -> (a -> Maybe l) -> Maybe [String] -> String -> Fixity -> Emb l a to :: Emb l a -> l -> a from :: Emb l a -> a -> Maybe l labels :: Emb l a -> Maybe [String] name :: Emb l a -> String fixity :: Emb l a -> Fixity data Fixity Nonfix :: Fixity Infix :: Int -> Fixity prec :: Fixity -> Int Infixl :: Int -> Fixity prec :: Fixity -> Int Infixr :: Int -> Fixity prec :: Fixity -> Int -- | Information about a datatype, including its fully qualified name and -- representation of its type arguments. data DT DT :: String -> (MTup R l) -> DT -- | An empty list of types data Nil Nil :: Nil -- | Cons for a list of types data (:*:) a l (:*:) :: a -> l -> :*: a l -- | A heterogeneous list data MTup r l MNil :: MTup r Nil (:+:) :: r a -> MTup r l -> MTup r (a :*: l) -- | A class of representable types class Rep a rep :: Rep a => R a rUnitEmb :: Emb Nil () rUnit :: R () rTup2 :: (Rep a, Rep b) => R (a, b) rPairEmb :: Emb (a :*: (b :*: Nil)) (a, b) rList :: Rep a => R [a] rNilEmb :: Emb Nil [a] rConsEmb :: Emb (a :*: ([a] :*: Nil)) [a] instance Rep a => Rep [a] instance (Rep a, Rep b) => Rep (a, b) instance Rep () instance (Rep a, Rep b) => Rep (a :=: b) instance (Rep a, Rep b) => Rep (a -> b) instance Rep a => Rep (IO a) instance Rep IOError instance Rep Rational instance Rep Double instance Rep Float instance Rep Integer instance Rep Char instance Rep Int instance Ord (R a) instance Eq (R a) instance Show (MTup R l) instance Show DT instance Show (R a) module Generics.RepLib.R1 data R1 ctx a Int1 :: R1 ctx Int Char1 :: R1 ctx Char Integer1 :: R1 ctx Integer Float1 :: R1 ctx Float Double1 :: R1 ctx Double Rational1 :: R1 ctx Rational IOError1 :: R1 ctx IOError IO1 :: ctx a -> R1 ctx (IO a) Arrow1 :: ctx a -> ctx b -> R1 ctx (a -> b) Data1 :: DT -> [Con ctx a] -> R1 ctx a Abstract1 :: DT -> R1 ctx a Equal1 :: ctx a -> ctx b -> R1 ctx (a :=: b) class Sat a dict :: Sat a => a class Rep a => Rep1 ctx a rep1 :: Rep1 ctx a => R1 ctx a -- | Access a representation, given a proxy getRepC :: Rep b => c b -> R b -- | Transform a parameterized rep to a vanilla rep toR :: R1 c a -> R a rTup2_1 :: (Rep a, Rep b) => ctx a -> ctx b -> R1 ctx (a, b) rList1 :: Rep a => ctx a -> ctx [a] -> R1 ctx [a] instance (Rep a, Sat (ctx a), Sat (ctx [a])) => Rep1 ctx [a] instance (Rep a, Sat (ctx a), Rep b, Sat (ctx b)) => Rep1 ctx (a, b) instance Rep1 ctx () instance (Rep a, Rep b, Sat (ctx a), Sat (ctx b)) => Rep1 ctx (a :=: b) instance (Rep a, Rep b, Sat (ctx a), Sat (ctx b)) => Rep1 ctx (a -> b) instance (Rep a, Sat (ctx a)) => Rep1 ctx (IO a) instance Rep1 ctx Rational instance Rep1 ctx IOError instance Rep1 ctx Double instance Rep1 ctx Float instance Rep1 ctx Integer instance Rep1 ctx Char instance Rep1 ctx Int instance Show (R1 c a) -- | Automatically derive representations and instance declarations for -- user defined datatypes. The typical use is $(derive [''MyType1, -- ''MyType2]) module Generics.RepLib.Derive -- | Generate representations (both basic and parameterized) for a list of -- types. derive :: [Name] -> Q [Dec] -- | Generate abstract representations for a list of types. derive_abstract :: [Name] -> Q [Dec] instance Applicative QN instance Functor QN instance Monad QN instance MonadWriter (Set Int) QN instance Quasi QN -- | Representations for Prelude types, necessary to (automatically) derive -- representations of user defined types. module Generics.RepLib.PreludeReps rTup7_1 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16, Rep f_17, Rep g_18) => (ctx_afaE a_12, ctx_afaE b_13, ctx_afaE c_14, ctx_afaE d_15, ctx_afaE e_16, ctx_afaE f_17, ctx_afaE g_18) -> R1 ctx_afaE ((,,,,,,) a_12 b_13 c_14 d_15 e_16 f_17 g_18) rTup7 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16, Rep f_17, Rep g_18) => R ((,,,,,,) a_12 b_13 c_14 d_15 e_16 f_17 g_18) rTup6_1 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16, Rep f_17) => (ctx_afa6 a_12, ctx_afa6 b_13, ctx_afa6 c_14, ctx_afa6 d_15, ctx_afa6 e_16, ctx_afa6 f_17) -> R1 ctx_afa6 ((,,,,,) a_12 b_13 c_14 d_15 e_16 f_17) rTup6 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16, Rep f_17) => R ((,,,,,) a_12 b_13 c_14 d_15 e_16 f_17) rTup5_1 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16) => (ctx_af9D a_12, ctx_af9D b_13, ctx_af9D c_14, ctx_af9D d_15, ctx_af9D e_16) -> R1 ctx_af9D ((,,,,) a_12 b_13 c_14 d_15 e_16) rTup5 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15, Rep e_16) => R ((,,,,) a_12 b_13 c_14 d_15 e_16) rTup4_1 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15) => (ctx_af9f a_12, ctx_af9f b_13, ctx_af9f c_14, ctx_af9f d_15) -> R1 ctx_af9f ((,,,) a_12 b_13 c_14 d_15) rTup4 :: (Rep a_12, Rep b_13, Rep c_14, Rep d_15) => R ((,,,) a_12 b_13 c_14 d_15) rTup3_1 :: (Rep a_12, Rep b_13, Rep c_14) => (ctx_af8W a_12, ctx_af8W b_13, ctx_af8W c_14) -> R1 ctx_af8W ((,,) a_12 b_13 c_14) rTup3 :: (Rep a_12, Rep b_13, Rep c_14) => R ((,,) a_12 b_13 c_14) rOrdering1 :: () -> () -> () -> R1 ctx_af8M Ordering rOrdering :: R Ordering rEither1 :: (Rep a_af8l, Rep b_af8m) => ctx_af8v a_af8l -> ctx_af8v b_af8m -> R1 ctx_af8v (Either a_af8l b_af8m) rEither :: (Rep a_af8l, Rep b_af8m) => R (Either a_af8l b_af8m) rMaybe1 :: Rep a_a1we => () -> ctx_af89 a_a1we -> R1 ctx_af89 (Maybe a_a1we) rMaybe :: Rep a_a1we => R (Maybe a_a1we) rBool1 :: () -> () -> R1 ctx_af82 Bool rBool :: R Bool instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0, Rep f0, Rep g0, Sat (ctx0 a0), Sat (ctx0 b0), Sat (ctx0 c0), Sat (ctx0 d0), Sat (ctx0 e0), Sat (ctx0 f0), Sat (ctx0 g0)) => Rep1 ctx0 (a0, b0, c0, d0, e0, f0, g0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0, Rep f0, Rep g0) => Rep (a0, b0, c0, d0, e0, f0, g0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0, Rep f0, Sat (ctx0 a0), Sat (ctx0 b0), Sat (ctx0 c0), Sat (ctx0 d0), Sat (ctx0 e0), Sat (ctx0 f0)) => Rep1 ctx0 (a0, b0, c0, d0, e0, f0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0, Rep f0) => Rep (a0, b0, c0, d0, e0, f0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0, Sat (ctx0 a0), Sat (ctx0 b0), Sat (ctx0 c0), Sat (ctx0 d0), Sat (ctx0 e0)) => Rep1 ctx0 (a0, b0, c0, d0, e0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Rep e0) => Rep (a0, b0, c0, d0, e0) instance (Rep a0, Rep b0, Rep c0, Rep d0, Sat (ctx0 a0), Sat (ctx0 b0), Sat (ctx0 c0), Sat (ctx0 d0)) => Rep1 ctx0 (a0, b0, c0, d0) instance (Rep a0, Rep b0, Rep c0, Rep d0) => Rep (a0, b0, c0, d0) instance (Rep a0, Rep b0, Rep c0, Sat (ctx0 a0), Sat (ctx0 b0), Sat (ctx0 c0)) => Rep1 ctx0 (a0, b0, c0) instance (Rep a0, Rep b0, Rep c0) => Rep (a0, b0, c0) instance Rep1 ctx0 Ordering instance Rep Ordering instance (Rep a0, Rep b0, Sat (ctx0 a0), Sat (ctx0 b0)) => Rep1 ctx0 (Either a0 b0) instance (Rep a0, Rep b0) => Rep (Either a0 b0) instance (Rep a0, Sat (ctx0 a0)) => Rep1 ctx0 (Maybe a0) instance Rep a0 => Rep (Maybe a0) instance Rep1 ctx0 Bool instance Rep Bool -- | Auxiliary operations to aid in the definition of type-indexed -- functions module Generics.RepLib.RepAux -- | Determine if two reps are for the same type eqR :: R a -> R b -> Bool -- | The type-safe cast operation, implicit arguments cast :: (Rep a, Rep b) => a -> Maybe b -- | The type-safe cast operation, explicit arguments castR :: R a -> R b -> a -> Maybe b -- | Leibniz equality between types, implicit representations gcast :: (Rep a, Rep b) => c a -> Maybe (c b) -- | Leibniz equality between types, explicit representations gcastR :: R a -> R b -> c a -> Maybe (c b) -- | Heterogeneous Ordering compareR :: R a -> R b -> Ordering -- | Given a list of constructor representations for a datatype, determine -- which constructor formed the datatype. findCon :: [Con ctx a] -> a -> Val ctx a -- | A datastructure to store the results of findCon data Val ctx a Val :: Emb l a -> MTup ctx l -> l -> Val ctx a -- | A fold left for heterogeneous lists foldl_l :: (forall a. Rep a => ctx a -> b -> a -> b) -> b -> (MTup ctx l) -> l -> b -- | A fold right operation for heterogeneous lists, that folds a function -- expecting a type type representation across each element of the list. foldr_l :: (forall a. Rep a => ctx a -> a -> b -> b) -> b -> (MTup ctx l) -> l -> b -- | A map for heterogeneous lists map_l :: (forall a. Rep a => ctx a -> a -> a) -> (MTup ctx l) -> l -> l -- | Transform a heterogeneous list in to a standard list mapQ_l :: (forall a. Rep a => ctx a -> a -> r) -> MTup ctx l -> l -> [r] -- | mapM for heterogeneous lists mapM_l :: Monad m => (forall a. Rep a => ctx a -> a -> m a) -> MTup ctx l -> l -> m l -- | Generate a heterogeneous list from metadata fromTup :: (forall a. Rep a => ctx a -> a) -> MTup ctx l -> l -- | Generate a heterogeneous list from metadata, in a monad fromTupM :: Monad m => (forall a. Rep a => ctx a -> m a) -> MTup ctx l -> m l -- | Generate a normal lists from metadata toList :: (forall a. Rep a => ctx a -> b) -> MTup ctx l -> [b] -- | A SYB style traversal type Traversal = forall a. Rep a => a -> a -- | SYB style query type type Query r = forall a. Rep a => a -> r -- | SYB style monadic map type type MapM m = forall a. Rep a => a -> m a -- | Map a traversal across the kids of a data structure gmapT :: Rep a => Traversal -> a -> a gmapQ :: Rep a => Query r -> a -> [r] gmapM :: (Rep a, Monad m) => MapM m -> a -> m a type Traversal1 ctx = forall a. Rep a => ctx a -> a -> a type Query1 ctx r = forall a. Rep a => ctx a -> a -> r type MapM1 ctx m = forall a. Rep a => ctx a -> a -> m a gmapT1 :: Rep1 ctx a => Traversal1 ctx -> a -> a gmapQ1 :: Rep1 ctx a => Query1 ctx r -> a -> [r] gmapM1 :: (Rep1 ctx a, Monad m) => MapM1 ctx m -> a -> m a data Typed a (:::) :: a -> R a -> Typed a data Spine a Constr :: a -> Spine a (:<>) :: Spine (a -> b) -> Typed a -> Spine b toSpine :: Rep a => a -> Spine a fromSpine :: Spine a -> a instance Ord DT instance Eq DT instance EqT R module Generics.RepLib.SYB.Aliases -- | Make a generic transformation; start from a type-specific case; -- preserve the term otherwise mkT :: (Rep a, Rep b) => (b -> b) -> a -> a -- | Make a generic query; start from a type-specific case; return a -- constant otherwise mkQ :: (Rep a, Rep b) => r -> (b -> r) -> a -> r -- | Make a generic monadic transformation; start from a type-specific -- case; resort to return otherwise mkM :: (Monad m, Rep a, Rep b) => (b -> m b) -> a -> m a -- | Make a generic monadic transformation for MonadPlus; use "const mzero" -- (i.e., failure) instead of return as default. mkMp :: (MonadPlus m, Rep a, Rep b) => (b -> m b) -> a -> m a -- | Make a generic builder; start from a type-specific ase; resort to no -- build (i.e., mzero) otherwise mkR :: (MonadPlus m, Rep a, Rep b) => m b -> m a -- | Flexible type extension ext0 :: (Rep a, Rep b) => c a -> c b -> c a -- | Extend a generic transformation by a type-specific case extT :: (Rep a, Rep b) => (a -> a) -> (b -> b) -> a -> a -- | Extend a generic query by a type-specific case extQ :: (Rep a, Rep b) => (a -> q) -> (b -> q) -> a -> q -- | Extend a generic monadic transformation by a type-specific case extM :: (Monad m, Rep a, Rep b) => (a -> m a) -> (b -> m b) -> a -> m a -- | Extend a generic MonadPlus transformation by a type-specific case extMp :: (MonadPlus m, Rep a, Rep b) => (a -> m a) -> (b -> m b) -> a -> m a -- | Extend a generic builder extB :: (Rep a, Rep b) => a -> b -> a -- | Extend a generic reader extR :: (Monad m, Rep a, Rep b) => m a -> m b -> m a -- | Generic transformations, i.e., take an "a" and return an "a" type GenericT = forall a. Rep a => a -> a -- | Generic queries of type "r", i.e., take any "a" and return an "r" type GenericQ r = forall a. Rep a => a -> r -- | Generic monadic transformations, i.e., take an "a" and compute an "a" type GenericM m = forall a. Rep a => a -> m a -- | Generic builders i.e., produce an "a". type GenericB = forall a. Rep a => a -- | Generic readers, say monadic builders, i.e., produce an "a" with the -- help of a monad "m". type GenericR m = forall a. Rep a => m a -- | The general scheme underlying generic functions assumed by gfoldl; -- there are isomorphisms such as GenericT = Generic T. type Generic c = forall a. Rep a => a -> c a -- | Wrapped generic functions; recall: [Generic c] would be legal but -- [Generic' c] not. data Generic' c Generic' :: Generic c -> Generic' c unGeneric' :: Generic' c -> Generic c -- | Other first-class polymorphic wrappers newtype GenericT' GT :: (forall a. Rep a => a -> a) -> GenericT' unGT :: GenericT' -> forall a. Rep a => a -> a newtype GenericQ' r GQ :: GenericQ r -> GenericQ' r unGQ :: GenericQ' r -> GenericQ r newtype GenericM' m GM :: (forall a. Rep a => a -> m a) -> GenericM' m unGM :: GenericM' m -> forall a. Rep a => a -> m a -- | Left-biased choice on maybies orElse :: Maybe a -> Maybe a -> Maybe a -- | Recover from the failure of monadic transformation by identity recoverMp :: MonadPlus m => GenericM m -> GenericM m -- | Recover from the failure of monadic query by a constant recoverQ :: MonadPlus m => r -> GenericQ (m r) -> GenericQ (m r) -- | Choice for monadic transformations choiceMp :: MonadPlus m => GenericM m -> GenericM m -> GenericM m -- | Choice for monadic queries choiceQ :: MonadPlus m => GenericQ (m r) -> GenericQ (m r) -> GenericQ (m r) -- | Derived from Data.Generics.Schemes Only modification: Data -- class becomes Rep class otherwise import our version of the -- libraries For now, missing somewhere (lacking mapMp) module Generics.RepLib.SYB.Schemes -- | Apply a transformation everywhere in bottom-up manner everywhere :: (forall a. Rep a => a -> a) -> (forall a. Rep a => a -> a) -- | Apply a transformation everywhere in top-down manner everywhere' :: (forall a. Rep a => a -> a) -> (forall a. Rep a => a -> a) -- | Variation on everywhere with an extra stop condition everywhereBut :: GenericQ Bool -> GenericT -> GenericT -- | Monadic variation on everywhere everywhereM :: Monad m => GenericM m -> GenericM m -- | Apply a monadic transformation at least somewhere somewhere :: -- MonadPlus m => GenericM m -> GenericM m -- -- Summarise all nodes in top-down, left-to-right order everything :: (r -> r -> r) -> GenericQ r -> GenericQ r -- | Get a list of all entities that meet a predicate listify :: Rep r => (r -> Bool) -> GenericQ [r] -- | Look up a subterm by means of a maybe-typed filter something :: GenericQ (Maybe u) -> GenericQ (Maybe u) -- | Bottom-up synthesis of a data structure; 1st argument z is the initial -- element for the synthesis; 2nd argument o is for reduction of results -- from subterms; 3rd argument f updates the synthesised data according -- to the given term synthesize :: s -> (s -> s -> s) -> GenericQ (s -> s) -> GenericQ s -- | Compute size of an arbitrary data structure gsize :: Rep a => a -> Int -- | Count the number of immediate subterms of the given term glength :: GenericQ Int -- | Determine depth of the given term gdepth :: GenericQ Int -- | Determine the number of all suitable nodes in a given term gcount :: GenericQ Bool -> GenericQ Int -- | Determine the number of all nodes in a given term gnodecount :: GenericQ Int -- | Determine the number of nodes of a given type in a given term gtypecount :: Rep a => a -> GenericQ Int -- | Find (unambiguously) an immediate subterm of a given type gfindtype :: (Rep x, Rep y) => x -> Maybe y -- | The module PreludeLib contains generic operations to derive members of -- the standard prelude classess: Eq, Bounded, Compare, Show (TODO: add -- Enum and Read) -- -- Although these classes may already be automatically derived via the -- deriving mechanism, this module is included for two reasons: -- --
-- import RepLib -- -- (repr1 ''T) -- make the Rep1 instance of T available -- -- instance Show T where -- showsPrec = showsPrecR1 rep1 -- showsPrecR1 is defined in this module ---- --