-- 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.2.1
module Data.RepLib.R
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
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
data DT
DT :: String -> (MTup R l) -> DT
data Con r a
Con :: (Emb l a) -> (MTup r l) -> Con r a
data Nil
Nil :: Nil
data (:*:) a l
(:*:) :: a -> l -> :*: a l
data MTup r l
MNil :: MTup ctx Nil
(:+:) :: r a -> MTup r l -> MTup r (a :*: l)
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 IOError
instance (Rep a) => Rep (IO a)
instance Rep Integer
instance Rep Float
instance Rep Rational
instance Rep Double
instance Rep Char
instance Rep Int
instance Eq (R a)
instance Show (MTup R l)
instance Show DT
instance Show (R a)
module Data.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
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
getRep :: (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]
rNil1 :: Con ctx [a]
rCons1 :: (Rep a) => ctx a -> ctx [a] -> Con 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, 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)
-- | Auxiliary operations to aid in the definition of type-indexed
-- functions
module Data.RepLib.RepAux
-- | Determine if two reps are for the same type
compR :: 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, implicity 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)
-- | 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
-- | 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:
--
--
-- - Deriving only works when datatypes are defined. This library
-- allows instances of these classes to be generated anywhere. For
-- example, suppose some other module contains the definition of the
-- datatype T and exposes all of its constructors, but, frustratingly,
-- does not derive an instance of the Show class.
--
--
-- You could define a Show instance of T in your own module with the
-- following code:
--
--
-- import RepLib
--
-- (repr1 ''T) -- make the Rep1 instance of T available
--
-- instance Show T where
-- showsPrec = showsPrecR1 rep1 -- showsPrecR1 is defined in this module
--
--
--
-- - This library also serves as a model for generic functions that are
-- slight modifications to these prelude operations. For example, if you
-- wanted to define reverse lexicographic ordering or an XML pretty
-- printer for datatypes, you might start here. This library is also a
-- good place to start learning how to define your own generic
-- operations, because the behavior of these operations should match the
-- deriving mechanism specified by Haskell 98.
--
module Data.RepLib.PreludeLib
data EqD a
-- | Polymorphic equality, given an R1 representation
eqR1 :: R1 EqD a -> a -> a -> Bool
data OrdD a
-- | Minimal completion of the Ord class
compareR1 :: R1 OrdD a -> a -> a -> Ordering
data BoundedD a
-- | To generate the Bounded class
minBoundR1 :: R1 BoundedD a -> a
-- | To generate the Bounded class
maxBoundR1 :: R1 BoundedD a -> a
data ShowD a
-- | Minimal completion of the show class
showsPrecR1 :: R1 ShowD a -> Int -> a -> ShowS
instance (Show a) => Sat (ShowD a)
instance (Bounded a) => Sat (BoundedD a)
instance (Ord a) => Sat (OrdD a)
instance (Eq a) => Sat (EqD a)
-- | code to automatically derive representations and instance declarations
-- for user defined datatypes.
module Data.RepLib.Derive
repr :: Name -> Q [Dec]
reprs :: [Name] -> Q [Dec]
repr1 :: Name -> Q [Dec]
repr1s :: [Name] -> Q [Dec]
-- | Automatically derive representations for prelude types
module Data.RepLib.PreludeReps
rBool1 :: R1 ctx[a70m] Bool
rBool :: R Bool
rMaybe1 :: (Rep a[a1ko]) => ctx[a70c] a[a1ko] -> R1 ctx[a70c] (Maybe a[a1ko])
rMaybe :: (Rep a[a1ko]) => R (Maybe a[a1ko])
rEither1 :: (Rep a[a6ZO], Rep b[a6ZN]) => ctx[a6ZX] a[a6ZO] -> ctx[a6ZX] b[a6ZN] -> R1 ctx[a6ZX] (Either a[a6ZO] b[a6ZN])
rEither :: (Rep a[a6ZO], Rep b[a6ZN]) => R (Either a[a6ZO] b[a6ZN])
rOrdering1 :: R1 ctx[a6ZG] Ordering
rOrdering :: R Ordering
rTup3_1 :: (Rep a[12], Rep b[13], Rep c[14]) => ctx[a6Zo] a[12] -> ctx[a6Zo] b[13] -> ctx[a6Zo] c[14] -> R1 ctx[a6Zo] ((,,) a[12] b[13] c[14])
rTup3 :: (Rep a[12], Rep b[13], Rep c[14]) => R ((,,) a[12] b[13] c[14])
rTup4_1 :: (Rep a[12], Rep b[13], Rep c[14], Rep d[15]) => ctx[a6Z1] a[12] -> ctx[a6Z1] b[13] -> ctx[a6Z1] c[14] -> ctx[a6Z1] d[15] -> R1 ctx[a6Z1] ((,,,) 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])
rTup5_1 :: (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16]) => ctx[a6Yz] a[12] -> ctx[a6Yz] b[13] -> ctx[a6Yz] c[14] -> ctx[a6Yz] d[15] -> ctx[a6Yz] e[16] -> R1 ctx[a6Yz] ((,,,,) 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])
rTup6_1 :: (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17]) => ctx[a6Y2] a[12] -> ctx[a6Y2] b[13] -> ctx[a6Y2] c[14] -> ctx[a6Y2] d[15] -> ctx[a6Y2] e[16] -> ctx[a6Y2] f[17] -> R1 ctx[a6Y2] ((,,,,,) 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])
rTup7_1 :: (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17], Rep g[18]) => ctx[a6Xq] a[12] -> ctx[a6Xq] b[13] -> ctx[a6Xq] c[14] -> ctx[a6Xq] d[15] -> ctx[a6Xq] e[16] -> ctx[a6Xq] f[17] -> ctx[a6Xq] g[18] -> R1 ctx[a6Xq] ((,,,,,,) 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])
instance Rep1 ctx[a70m] Bool
instance Rep Bool
instance (Rep a[a1ko], Sat (ctx[a70c] a[a1ko])) => Rep1 ctx[a70c] (Maybe a[a1ko])
instance (Rep a[a1ko]) => Rep (Maybe a[a1ko])
instance (Rep a[a6ZO], Rep b[a6ZN], Sat (ctx[a6ZX] a[a6ZO]), Sat (ctx[a6ZX] b[a6ZN])) => Rep1 ctx[a6ZX] (Either a[a6ZO] b[a6ZN])
instance (Rep a[a6ZO], Rep b[a6ZN]) => Rep (Either a[a6ZO] b[a6ZN])
instance Rep1 ctx[a6ZG] Ordering
instance Rep Ordering
instance (Rep a[12], Rep b[13], Rep c[14], Sat (ctx[a6Zo] a[12]), Sat (ctx[a6Zo] b[13]), Sat (ctx[a6Zo] c[14])) => Rep1 ctx[a6Zo] (a[12], b[13], c[14])
instance (Rep a[12], Rep b[13], Rep c[14]) => Rep (a[12], b[13], c[14])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Sat (ctx[a6Z1] a[12]), Sat (ctx[a6Z1] b[13]), Sat (ctx[a6Z1] c[14]), Sat (ctx[a6Z1] d[15])) => Rep1 ctx[a6Z1] (a[12], b[13], c[14], d[15])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15]) => Rep (a[12], b[13], c[14], d[15])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Sat (ctx[a6Yz] a[12]), Sat (ctx[a6Yz] b[13]), Sat (ctx[a6Yz] c[14]), Sat (ctx[a6Yz] d[15]), Sat (ctx[a6Yz] e[16])) => Rep1 ctx[a6Yz] (a[12], b[13], c[14], d[15], e[16])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16]) => Rep (a[12], b[13], c[14], d[15], e[16])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17], Sat (ctx[a6Y2] a[12]), Sat (ctx[a6Y2] b[13]), Sat (ctx[a6Y2] c[14]), Sat (ctx[a6Y2] d[15]), Sat (ctx[a6Y2] e[16]), Sat (ctx[a6Y2] f[17])) => Rep1 ctx[a6Y2] (a[12], b[13], c[14], d[15], e[16], f[17])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17]) => Rep (a[12], b[13], c[14], d[15], e[16], f[17])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17], Rep g[18], Sat (ctx[a6Xq] a[12]), Sat (ctx[a6Xq] b[13]), Sat (ctx[a6Xq] c[14]), Sat (ctx[a6Xq] d[15]), Sat (ctx[a6Xq] e[16]), Sat (ctx[a6Xq] f[17]), Sat (ctx[a6Xq] g[18])) => Rep1 ctx[a6Xq] (a[12], b[13], c[14], d[15], e[16], f[17], g[18])
instance (Rep a[12], Rep b[13], Rep c[14], Rep d[15], Rep e[16], Rep f[17], Rep g[18]) => Rep (a[12], b[13], c[14], d[15], e[16], f[17], g[18])
-- | A library of specializable, type-indexed functions
module Data.RepLib.Lib
-- | Produce all children of a datastructure with the same type Note that
-- subtrees is available for all representable types. For those that are
-- not recursive datatypes, subtrees will always return the empty list.
-- But, these trivial instances are convenient to have for the Shrink
-- operation below.
subtrees :: (Rep a) => a -> [a]
-- | deepSeq recursively forces the evaluation of its entire argument.
deepSeq :: (Rep a) => a -> b -> b
-- | rnf forces the evaluation of *datatypes* to their normal forms.
-- However, other types are left alone and not forced.
rnf :: (Rep a) => a -> a
-- | Add together all of the Ints in a datastructure
class (Rep1 GSumD a) => GSum a
gsum :: (GSum a) => a -> Int
-- | Create a zero element of a type
class (Rep1 ZeroD a) => Zero a
zero :: (Zero a) => a
-- | Generate elements of a type up to a certain depth
class (Rep1 GenerateD a) => Generate a
generate :: (Generate a) => Int -> [a]
-- | enumerate the elements of a type, in DFS order.
class (Rep1 EnumerateD a) => Enumerate a
enumerate :: (Enumerate a) => [a]
class (Rep1 ShrinkD a) => Shrink a
shrink :: (Shrink a) => a -> [a]
class (Rep1 (LreduceD b) a) => Lreduce b a
lreduce :: (Lreduce b a) => b -> a -> b
class (Rep1 (RreduceD b) a) => Rreduce b a
rreduce :: (Rreduce b a) => a -> b -> b
class Fold f
foldRight :: (Fold f, Rep a) => (a -> b -> b) -> f a -> b -> b
foldLeft :: (Fold f, Rep a) => (b -> a -> b) -> b -> f a -> b
crush :: (Rep a, Fold t) => (a -> a -> a) -> a -> t a -> a
gproduct :: (Rep a, Num a, Fold t) => t a -> a
gand :: (Fold t) => t Bool -> Bool
gor :: (Fold t) => t Bool -> Bool
flatten :: (Rep a, Fold t) => t a -> [a]
count :: (Rep a, Fold t) => t a -> Int
comp :: (Rep a, Fold t) => t (a -> a) -> a -> a
gconcat :: (Rep a, Fold t) => t [a] -> [a]
gall :: (Rep a, Fold t) => (a -> Bool) -> t a -> Bool
gany :: (Rep a, Fold t) => (a -> Bool) -> t a -> Bool
gelem :: (Rep a, Eq a, Fold t) => a -> t a -> Bool
data GSumD a
GSumD :: (a -> Int) -> GSumD a
gsumD :: GSumD a -> a -> Int
data ZeroD a
ZD :: a -> ZeroD a
zeroD :: ZeroD a -> a
data GenerateD a
GenerateD :: (Int -> [a]) -> GenerateD a
generateD :: GenerateD a -> Int -> [a]
data EnumerateD a
EnumerateD :: [a] -> EnumerateD a
enumerateD :: EnumerateD a -> [a]
data ShrinkD a
ShrinkD :: (a -> [a]) -> ShrinkD a
shrinkD :: ShrinkD a -> a -> [a]
data LreduceD b a
LreduceD :: (b -> a -> b) -> LreduceD b a
lreduceD :: LreduceD b a -> b -> a -> b
data RreduceD b a
RreduceD :: (a -> b -> b) -> RreduceD b a
rreduceD :: RreduceD b a -> a -> b -> b
rnfR :: R a -> a -> a
deepSeqR :: R a -> a -> b -> b
gsumR1 :: R1 GSumD a -> a -> Int
zeroR1 :: R1 ZeroD a -> a
generateR1 :: R1 GenerateD a -> Int -> [a]
enumerateR1 :: R1 EnumerateD a -> [a]
lreduceR1 :: R1 (LreduceD b) a -> b -> a -> b
rreduceR1 :: R1 (RreduceD b) a -> a -> b -> b
instance Fold []
instance (Rreduce c a) => Rreduce c [a]
instance (Rreduce c a, Rreduce c b) => Rreduce c (a, b)
instance Rreduce b Bool
instance Rreduce b Char
instance Rreduce b ()
instance Rreduce b Int
instance (Lreduce c a) => Lreduce c [a]
instance (Lreduce c a, Lreduce c b) => Lreduce c (a, b)
instance Lreduce b Bool
instance Lreduce b Char
instance Lreduce b ()
instance Lreduce b Int
instance (Lreduce b a) => Sat (LreduceD b a)
instance (Rreduce b a) => Sat (RreduceD b a)
instance (Shrink a, Shrink b) => Shrink (a, b)
instance Shrink ()
instance Shrink Char
instance (Shrink a) => Shrink [a]
instance Shrink Int
instance Monad M
instance (Shrink a) => Sat (ShrinkD a)
instance (Enumerate a) => Sat (EnumerateD a)
instance (Generate a) => Generate [a]
instance (Generate a, Generate b) => Generate (a, b)
instance Generate ()
instance Generate Double
instance Generate Float
instance Generate Integer
instance Generate Char
instance Generate Int
instance (Generate a) => Sat (GenerateD a)
instance (Zero a) => Zero [a]
instance (Zero a, Zero b) => Zero (a, b)
instance Zero Bool
instance Zero ()
instance Zero IOError
instance Zero Double
instance Zero Float
instance Zero Integer
instance (Zero a, Zero b) => Zero (a -> b)
instance Zero Char
instance Zero Int
instance (Zero a) => Sat (ZeroD a)
instance (GSum a) => GSum [a]
instance (GSum a, GSum b) => GSum (a, b)
instance GSum Double
instance GSum Char
instance GSum Integer
instance GSum ()
instance GSum Bool
instance GSum Int
instance GSum Float
instance (GSum a) => Sat (GSumD a)
module Data.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 Data.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
module Data.RepLib.Unify
data Proxy a
type UnifyError = String
type UM n a b = ErrorT UnifyError (State (UnificationState n a)) b
data UnifySubD n a b
UnifySubD :: (Proxy (n, a) -> b -> b -> UM n a ()) -> (n -> a -> b -> b) -> (n -> Proxy a -> b -> Bool) -> UnifySubD n a b
unifyStepD :: UnifySubD n a b -> Proxy (n, a) -> b -> b -> UM n a ()
substD :: UnifySubD n a b -> n -> a -> b -> b
occursCheckD :: UnifySubD n a b -> n -> Proxy a -> b -> Bool
data UConstraint n a
UC :: (UnifySubD n a b) -> b -> b -> UConstraint n a
data UnificationState n a
UState :: [UConstraint n a] -> [(n, a)] -> UnificationState n a
uConstraints :: UnificationState n a -> [UConstraint n a]
uSubst :: UnificationState n a -> [(n, a)]
class (Eq n, Show n, Show a, Show b, HasVar n a) => Unify n a b
unifyStep :: (Unify n a b) => Proxy (n, a) -> b -> b -> UM n a ()
-- | Generic unifyStep. almost identical to polymorphic equality
unifyStepR1 :: (Eq n, Show n, Show a, Show b, HasVar n a) => R1 (UnifySubD n a) b -> Proxy (n, a) -> b -> b -> UM n a ()
addConstraintsRL1 :: MTup (UnifySubD n a) l -> Proxy (n, a) -> l -> l -> UM n a ()
dequeueConstraint :: UM n a (Maybe (UConstraint n a))
queueConstraint :: UConstraint n a -> UM n a ()
extendSubstitution :: (HasVar n a, Eq n, Show n, Show a, Rep1 (UnifySubD n a) a) => (n, a) -> UM n a ()
solveUnification :: (HasVar n a, Eq n, Show n, Show a, Rep1 (UnifySubD n a) a) => [(a, a)] -> Maybe [(n, a)]
solveUnification' :: (HasVar n a, Eq n, Show n, Show a, Show b, Rep1 (UnifySubD n a) b) => Proxy (n, a) -> [(b, b)] -> Maybe [(n, a)]
class HasVar a b
is_var :: (HasVar a b) => b -> Maybe a
var :: (HasVar a b) => a -> b
class Subst a t t'
subst :: (Subst a t t') => a -> t -> t' -> t'
substR1 :: (Rep1 (UnifySubD a t) t') => R1 (UnifySubD a t) t' -> a -> t -> t' -> t'
class Occurs n a b
occursCheck :: (Occurs n a b) => n -> Proxy a -> b -> Bool
occursCheckR1 :: (Rep1 (UnifySubD n a) b) => R1 (UnifySubD n a) b -> n -> Proxy a -> b -> Bool
instance [incoherent] (Eq n, HasVar n a, Rep1 (UnifySubD n a) a) => Occurs n a a
instance [incoherent] (Rep1 (UnifySubD n a) b) => Occurs n a b
instance [incoherent] (Eq a, HasVar a t, Rep1 (UnifySubD a t) t) => Subst a t t
instance [incoherent] (Rep1 (UnifySubD a t) t') => Subst a t t'
instance [incoherent] (Eq n, Show n, Show a, HasVar n a, Rep1 (UnifySubD n a) a) => Unify n a a
instance [incoherent] (Eq n, Show n, Show a, Show b, HasVar n a, Rep1 (UnifySubD n a) b) => Unify n a b
instance [incoherent] (Unify n a b, Subst n a b, Occurs n a b) => Sat (UnifySubD n a b)
module Data.RepLib