Safe Haskell | None |
---|---|
Language | Haskell2010 |
A convinience module which re-exports common basic functionality of `syntax-tree`
Synopsis
- type (#) k p = Tree (GetKnot k) p
- type Tree k p = (k (Knot p) :: Type)
- type family GetKnot k where ...
- newtype Knot = Knot (Knot -> Type)
- asTree :: Tree k p -> Tree k p
- data Product f g a = Pair (f a) (g a)
- class KNodes (k :: Knot -> Type) where
- type KNodesConstraint k (c :: (Knot -> Type) -> Constraint) :: Constraint
- data KWitness k :: (Knot -> Type) -> Type
- kLiftConstraint :: KNodesConstraint k c => KWitness k n -> Proxy c -> (c n => r) -> r
- (#>) :: (KNodes k, KNodesConstraint k c) => Proxy c -> (c n => r) -> KWitness k n -> r
- (#*#) :: (KNodes k, KNodesConstraint k c) => Proxy c -> (KWitness k n -> c n => r) -> KWitness k n -> r
- class KNodes k => KPointed k where
- class KNodes k => KFunctor k where
- mappedK1 :: forall k n p q. (KFunctor k, KNodesConstraint k ((~) n)) => Setter (Tree k p) (Tree k q) (Tree p n) (Tree q n)
- class (KPointed k, KApply k) => KApplicative k
- class KFunctor k => KApply k where
- liftK2 :: KApply k => (forall n. KWitness k n -> Tree p n -> Tree q n -> Tree r n) -> Tree k p -> Tree k q -> Tree k r
- makeKApplicativeBases :: Name -> DecsQ
- class KNodes k => KFoldable k where
- traverseK_ :: (Applicative f, KFoldable k) => (forall c. KWitness k c -> Tree m c -> f ()) -> Tree k m -> f ()
- traverseK1_ :: forall f k n p. (Applicative f, KFoldable k, KNodesConstraint k ((~) n)) => (Tree p n -> f ()) -> Tree k p -> f ()
- class (KFunctor k, KFoldable k) => KTraversable k where
- sequenceK :: Applicative f => Tree k (ContainedK f p) -> f (Tree k p)
- traverseK :: (Applicative f, KTraversable k) => (forall n. KWitness k n -> Tree p n -> f (Tree q n)) -> Tree k p -> f (Tree k q)
- traverseK1 :: (KTraversable k, KNodesConstraint k ((~) n)) => Traversal (Tree k p) (Tree k q) (Tree p n) (Tree q n)
- makeKTraversableApplyAndBases :: Name -> DecsQ
- makeKTraversableAndBases :: Name -> DecsQ
- newtype Pure k = Pure (k # Pure)
- _Pure :: Iso (Tree Pure k) (Tree Pure j) (Tree k Pure) (Tree j Pure)
- (&#) :: a -> (a -> Tree k Pure) -> Tree Pure k
- class Show (KPlain k) => KHasPlain k where
- makeKHasPlain :: [Name] -> DecsQ
- newtype ANode c k = MkANode (k # c)
- _ANode :: Iso (Tree (ANode c0) k0) (Tree (ANode c1) k1) (Tree k0 c0) (Tree k1 c1)
- makeZipMatch :: Name -> DecsQ
- class (KTraversable k, Recursively KFunctor k, Recursively KFoldable k) => RTraversable k
- class RNodes k => Recursively c k where
- recursively :: Proxy (c k) -> Dict (c k, KNodesConstraint k (Recursively c))
- class KNodes k => RNodes k
- data Ann a k = Ann {}
- ann :: forall a k. Lens' (Ann a k) a
- annotations :: forall k a b. RTraversable k => Traversal (Tree (Ann a) k) (Tree (Ann b) k) a b
Documentation
type family GetKnot k where ... Source #
A type-level getter for the type constructor encoded in Knot
.
Notes:
- If
DataKinds
supported lifting field getters this would had been replaced with the type's getter. GetKnot
is injective, but due to no support for constrained type families, that's not expressible at the moment.- Because
GetKnot
can't declared as bijective, uses of it may restrict inference. In those cases wrapping terms with theasTree
helper assists Haskell's type inference as if Haskell knew thatGetKnot
was bijective.
A Kind
for nested higher-kinded data.
Instances
A PolyKinds
variant of Product
.
Note that the original Product
is poly-kinded
in its type, but not in its instances such as Eq
.
Pair (f a) (g a) |
Instances
class KNodes (k :: Knot -> Type) where Source #
KNodes
allows lifting a constraint to the child nodes of a Knot
by using the KNodesConstraint
type family.
It also provides some methods to combine and process child node constraints.
Various classes like KFunctor
build upon KNodes
to provide methods such as mapKWith
which provide a rank-n function
for processing child nodes which requires a constraint on the nodes.
type KNodesConstraint k (c :: (Knot -> Type) -> Constraint) :: Constraint Source #
Lift a constraint to apply to the child nodes
data KWitness k :: (Knot -> Type) -> Type Source #
KWitness k n
is a witness that n
is a node of k
kLiftConstraint :: KNodesConstraint k c => KWitness k n -> Proxy c -> (c n => r) -> r Source #
Lift a rank-n value with a constraint which the child nodes satisfy to a function from a node witness.
Instances
(#>) :: (KNodes k, KNodesConstraint k c) => Proxy c -> (c n => r) -> KWitness k n -> r infixr 0 Source #
Proxy
c #> r replaces the witness parameter of
r@ with a constraint on the witnessed node
(#*#) :: (KNodes k, KNodesConstraint k c) => Proxy c -> (KWitness k n -> c n => r) -> KWitness k n -> r infixr 0 Source #
A variant of #>
which does not consume the witness parameter.
Proxy
c0 Proxy c1 #> r
brings into context both the c0 n
and c1 n
constraints.
class KNodes k => KPointed k where Source #
pureK :: (forall n. KWitness k n -> Tree p n) -> Tree k p Source #
Construct a value from a generator of k
's nodes
(a generator which can generate a tree of any type given a witness that it is a node of k
)
Instances
class KNodes k => KFunctor k where Source #
Instances
mappedK1 :: forall k n p q. (KFunctor k, KNodesConstraint k ((~) n)) => Setter (Tree k p) (Tree k q) (Tree p n) (Tree q n) Source #
class (KPointed k, KApply k) => KApplicative k Source #
A variant of Applicative
for Knot
s.
Instances
(KPointed k, KApply k) => KApplicative k Source # | |
Defined in AST.Class.Apply |
class KFunctor k => KApply k where Source #
A type which has KApply
and KPointed
instances also has KApplicative
,
which is the equivalent to the Applicative
class.
zipK :: Tree k p -> Tree k q -> Tree k (Product p q) Source #
Combine child values
>>>
zipK (Person name0 age0) (Person name1 age1)
Person (Pair name0 name1) (Pair age0 age1)
Instances
liftK2 :: KApply k => (forall n. KWitness k n -> Tree p n -> Tree q n -> Tree r n) -> Tree k p -> Tree k q -> Tree k r Source #
makeKApplicativeBases :: Name -> DecsQ Source #
Generate instances of KApply
,
KFunctor
, KPointed
and KNodes
,
which together form KApplicative
.
class KNodes k => KFoldable k where Source #
Instances
traverseK_ :: (Applicative f, KFoldable k) => (forall c. KWitness k c -> Tree m c -> f ()) -> Tree k m -> f () Source #
traverseK1_ :: forall f k n p. (Applicative f, KFoldable k, KNodesConstraint k ((~) n)) => (Tree p n -> f ()) -> Tree k p -> f () Source #
class (KFunctor k, KFoldable k) => KTraversable k where Source #
A variant of Traversable
for Knot
s
sequenceK :: Applicative f => Tree k (ContainedK f p) -> f (Tree k p) Source #
KTraversable
variant of sequenceA
Instances
traverseK :: (Applicative f, KTraversable k) => (forall n. KWitness k n -> Tree p n -> f (Tree q n)) -> Tree k p -> f (Tree k q) Source #
KTraversable
variant of traverse
traverseK1 :: (KTraversable k, KNodesConstraint k ((~) n)) => Traversal (Tree k p) (Tree k q) (Tree p n) (Tree q n) Source #
KTraversable
variant of traverse
for Knot
s with a single node type.
It is a valid Traversal
as it avoids using RankNTypes
.
makeKTraversableAndBases :: Name -> DecsQ Source #
Generate a KTraversable
instance along with the instance of its base classes:
KFoldable
, KFunctor
, and KNodes
.
A Knot
to express the simplest plain form of a nested higher-kinded data structure
Instances
ANode c
is a Knot
with a single child node of type c
Instances
class (KTraversable k, Recursively KFunctor k, Recursively KFoldable k) => RTraversable k Source #
A class of Knot
s which recursively implement KTraversable
Instances
RTraversable Pure Source # | |
Defined in AST.Class.Recursive | |
RTraversable Prune Source # | |
Defined in AST.Knot.Prune | |
Recursive RTraversable Source # | |
Defined in AST.Class.Recursive recurse :: (KNodes k, RTraversable k) => Proxy (RTraversable k) -> Dict (KNodesConstraint k RTraversable) Source # | |
Traversable f => RTraversable (F f) Source # | |
Defined in AST.Knot.Functor recursiveKTraversable :: Proxy (F f) -> Dict (KNodesConstraint (F f) RTraversable) | |
RTraversable (Ann a) Source # | |
Defined in AST.Knot.Ann recursiveKTraversable :: Proxy (Ann a) -> Dict (KNodesConstraint (Ann a) RTraversable) | |
RTraversable (Const a :: Knot -> Type) Source # | |
Defined in AST.Class.Recursive recursiveKTraversable :: Proxy (Const a) -> Dict (KNodesConstraint (Const a) RTraversable) | |
(KTraversable (Scheme v t), RTraversable t) => RTraversable (Scheme v t) Source # | |
Defined in AST.Term.Scheme recursiveKTraversable :: Proxy (Scheme v t) -> Dict (KNodesConstraint (Scheme v t) RTraversable) |
class RNodes k => Recursively c k where Source #
A constraint lifted to apply recursively.
Note that in cases where a constraint has dependencies other than RNodes
,
one will want to create a class such as RTraversable to capture the dependencies,
otherwise using it in class contexts will be quite unergonomic.
Nothing
recursively :: Proxy (c k) -> Dict (c k, KNodesConstraint k (Recursively c)) Source #
recursively :: (c k, KNodesConstraint k (Recursively c)) => Proxy (c k) -> Dict (c k, KNodesConstraint k (Recursively c)) Source #
Instances
class KNodes k => RNodes k Source #
Instances
RNodes Pure Source # | |
Defined in AST.Class.Recursive recursiveKNodes :: Proxy Pure -> Dict (KNodesConstraint Pure RNodes) | |
RNodes Prune Source # | |
Defined in AST.Knot.Prune recursiveKNodes :: Proxy Prune -> Dict (KNodesConstraint Prune RNodes) | |
Recursive RNodes Source # | |
RNodes (F f) Source # | |
Defined in AST.Knot.Functor recursiveKNodes :: Proxy (F f) -> Dict (KNodesConstraint (F f) RNodes) | |
RNodes (Ann a) Source # | |
Defined in AST.Knot.Ann recursiveKNodes :: Proxy (Ann a) -> Dict (KNodesConstraint (Ann a) RNodes) | |
RNodes (Const a :: Knot -> Type) Source # | |
Defined in AST.Class.Recursive recursiveKNodes :: Proxy (Const a) -> Dict (KNodesConstraint (Const a) RNodes) | |
RNodes t => RNodes (Scheme v t) Source # | |
Defined in AST.Term.Scheme recursiveKNodes :: Proxy (Scheme v t) -> Dict (KNodesConstraint (Scheme v t) RNodes) |
A Knot
which adds an annotation to every node in a tree
Instances
annotations :: forall k a b. RTraversable k => Traversal (Tree (Ann a) k) (Tree (Ann b) k) a b Source #
A Traversal
from an annotated tree to its annotations