Safe Haskell | None |
---|---|
Language | GHC2021 |
Data.HTree.Tree
Description
Synopsis
- data TyTree (k1 :: k) where
- type TyForest (a :: k) = [TyTree a]
- data HTree (f :: k -> Type) (t :: TyTree k) where
- type HForest (f :: k -> Type) (ts :: TyForest k) = HList (HTree f) ts
- hmap :: forall {k} f g (t :: TyTree k). (forall (a :: k). f a -> g a) -> HTree f t -> HTree g t
- hcmap :: forall {k} f g (t :: TyTree k). forall (c :: k -> Constraint) -> AllTree c t => (forall (a :: k). c a => f a -> g a) -> HTree f t -> HTree g t
- type family TreeMap (f :: k -> l) (t :: TyTree k) :: TyTree l where ...
- type family ForestMap (f :: k -> l) (t :: TyForest k) :: TyForest l where ...
- htraverse :: forall {k} h f g (t :: TyTree k). Applicative h => (forall (a :: k). f a -> h (g a)) -> HTree f t -> h (HTree g t)
- hctraverse :: forall {k} h f g (t :: TyTree k). forall (c :: k -> Constraint) -> (AllTree c t, Applicative h) => (forall (a :: k). c a => f a -> h (g a)) -> HTree f t -> h (HTree g t)
- hFoldMap :: forall {k} f (t :: TyTree k) b. Semigroup b => (forall (a :: k). f a -> b) -> HTree f t -> b
- hcFoldMap :: forall {k} f (t :: TyTree k) b. forall (c :: k -> Constraint) -> (AllTree c t, Semigroup b) => (forall (a :: k). c a => f a -> b) -> HTree f t -> b
- hFlatten :: forall {k} (f :: k -> Type) (t :: TyTree k). HTree f t -> HList f (FlattenTree t)
- type family FlattenTree (t :: TyTree k) :: [k] where ...
- type family FlattenForest (f :: TyForest k) :: [k] where ...
- data Path (k1 :: k) (t :: TyTree k) where
- Here :: forall {k} (k1 :: k) (ts :: TyForest k). Path k1 ('TyNode k1 ts)
- Deeper :: forall {k} (k1 :: k) (b :: k) (t1 :: TyTree k) (ts :: [TyTree k]). Path k1 t1 -> Path k1 ('TyNode b (t1 ': ts))
- Farther :: forall {k} (k1 :: k) (b :: k) (t1 :: TyTree k) (ts :: [TyTree k]). Path k1 ('TyNode b ts) -> Path k1 ('TyNode b (t1 ': ts))
- replaceAt :: forall {k} (typ :: k) (t :: TyTree k) f. Path typ t -> f typ -> HTree f t -> HTree f t
- type family AllTree (c :: k -> Constraint) (ts :: TyTree k) where ...
- class AllTree c ts => AllTreeC (c :: k -> Constraint) (ts :: TyTree k)
- type family AllForest (c :: k -> Constraint) (t :: TyForest k) where ...
- allTopHTree :: forall {k} (f :: k -> Type) (t :: TyTree k). HTree f t -> Dict (AllTree (Top :: k -> Constraint) t)
- allTopHForest :: forall {k} (f :: k -> Type) (t :: TyForest k). HForest f t -> Dict (AllForest (Top :: k -> Constraint) t)
type level tree
data TyTree (k1 :: k) where Source #
a type level rose-tree that is only intended to store something of a certain kind, e.g. Type
Instances
HasField' strat typ t => Decide strat 'False typ ('TyNode typ' (t ': ts')) Source # | |
HasField' strat typ ('TyNode typ' ts) => Decide strat 'True typ ('TyNode typ' (t' ': ts)) Source # | |
HasField' 'BFS typ ('TyNode typ (t ': ts)) Source # | |
HasField' 'BFS typ ('TyNode typ ('[] :: [TyTree Type])) Source # | |
Decide 'BFS (AnyElem typ ts) typ ('TyNode typ' (t ': ts)) => HasField' 'BFS typ ('TyNode typ' (t ': ts)) Source # | |
HasField' 'DFS typ ('TyNode typ (t ': ts)) Source # | |
HasField' 'DFS typ ('TyNode typ ('[] :: [TyTree Type])) Source # | |
Decide 'DFS (Not (Elem typ t)) typ ('TyNode typ' (t ': ts)) => HasField' 'DFS typ ('TyNode typ' (t ': ts)) Source # | |
(forall x. Eq x => Eq (f x), Typeable f) => Eq (ETree (Has (Both (Typeable :: Type -> Constraint) Eq) f)) Source # | |
Defined in Data.HTree.Existential |
heterogeneous tree
data HTree (f :: k -> Type) (t :: TyTree k) where Source #
a heterogeneous rose tree indexed by a TyTree
Constructors
HNode :: forall {k} (f :: k -> Type) (a :: k) (ts :: TyForest k). f a -> HForest f ts -> HTree f ('TyNode a ts) infixr 4 |
Bundled Patterns
pattern HLeaf :: forall {a1} f (a2 :: a1). f a2 -> HTree f ('TyNode a2 ('[] :: [TyTree a1])) | a pattern synonym for the leaf of an HTree |
Instances
(HasField' 'BFS (Labeled l typ) t, Functor f) => HasField (l :: k) (HTree f t) (f typ) Source # | |
Defined in Data.HTree.Labeled | |
(forall x. Eq x => Eq (f x), Typeable f) => Eq (ETree (Has (Both (Typeable :: Type -> Constraint) Eq) f)) Source # | |
Defined in Data.HTree.Existential | |
(Show (f a2), Show (HForest f t)) => Show (HTree f ('TyNode a2 t)) Source # | |
(Eq (f a2), Eq (HForest f t)) => Eq (HTree f ('TyNode a2 t)) Source # | |
type HForest (f :: k -> Type) (ts :: TyForest k) = HList (HTree f) ts Source #
A forest of heterogeneous rose trees
mapping
value level
hmap :: forall {k} f g (t :: TyTree k). (forall (a :: k). f a -> g a) -> HTree f t -> HTree g t Source #
map a function over an HTree
hcmap :: forall {k} f g (t :: TyTree k). forall (c :: k -> Constraint) -> AllTree c t => (forall (a :: k). c a => f a -> g a) -> HTree f t -> HTree g t Source #
map a function with a constraint over an HTree
type level
type family TreeMap (f :: k -> l) (t :: TyTree k) :: TyTree l where ... Source #
map a functor over a TyTree
type family ForestMap (f :: k -> l) (t :: TyForest k) :: TyForest l where ... Source #
map a functor over a TyForest
traversing
htraverse :: forall {k} h f g (t :: TyTree k). Applicative h => (forall (a :: k). f a -> h (g a)) -> HTree f t -> h (HTree g t) Source #
traverse a structure with a function
hctraverse :: forall {k} h f g (t :: TyTree k). forall (c :: k -> Constraint) -> (AllTree c t, Applicative h) => (forall (a :: k). c a => f a -> h (g a)) -> HTree f t -> h (HTree g t) Source #
traverse a structure such that a constraint holds; this is the workhorse of mapping and traversing
folding
value level
hFoldMap :: forall {k} f (t :: TyTree k) b. Semigroup b => (forall (a :: k). f a -> b) -> HTree f t -> b Source #
monoidally folds down a tree to a single value, this is similar to foldMap
hcFoldMap :: forall {k} f (t :: TyTree k) b. forall (c :: k -> Constraint) -> (AllTree c t, Semigroup b) => (forall (a :: k). c a => f a -> b) -> HTree f t -> b Source #
monoidally folds down a tree to a single value using a constraint on
the element in the wrapping functor, this is similar to foldMap
hFlatten :: forall {k} (f :: k -> Type) (t :: TyTree k). HTree f t -> HList f (FlattenTree t) Source #
flatten a heterogeneous tree down to a heterogeneous list
type level
type family FlattenTree (t :: TyTree k) :: [k] where ... Source #
a type family that flattens a tree down to a list
Equations
FlattenTree ('TyNode x xs :: TyTree k) = x ': FlattenForest xs |
type family FlattenForest (f :: TyForest k) :: [k] where ... Source #
a type family that flattens a forest down to a list
Equations
FlattenForest ('[] :: [TyTree k]) = '[] :: [k] | |
FlattenForest (x ': xs :: [TyTree k]) = FlattenTree x ++ FlattenForest xs |
paths into the htree and things you can do with those
data Path (k1 :: k) (t :: TyTree k) where Source #
provides evidence that an element is in the tree by providing a path to the element
Constructors
Here :: forall {k} (k1 :: k) (ts :: TyForest k). Path k1 ('TyNode k1 ts) | |
Deeper :: forall {k} (k1 :: k) (b :: k) (t1 :: TyTree k) (ts :: [TyTree k]). Path k1 t1 -> Path k1 ('TyNode b (t1 ': ts)) | |
Farther :: forall {k} (k1 :: k) (b :: k) (t1 :: TyTree k) (ts :: [TyTree k]). Path k1 ('TyNode b ts) -> Path k1 ('TyNode b (t1 ': ts)) |
replaceAt :: forall {k} (typ :: k) (t :: TyTree k) f. Path typ t -> f typ -> HTree f t -> HTree f t Source #
replace an element at a certain path.
helpful constraints
type family AllTree (c :: k -> Constraint) (ts :: TyTree k) where ... Source #
a constraint holds for all elements in the tree
Equations
AllTree (c :: k -> Constraint) ('TyNode x ts :: TyTree k) = (c x, AllForest c ts) |
class AllTree c ts => AllTreeC (c :: k -> Constraint) (ts :: TyTree k) Source #
constraint synonym for AllTree
Instances
AllTree c ts => AllTreeC (c :: k -> Constraint) (ts :: TyTree k) Source # | |
Defined in Data.HTree.Tree |
type family AllForest (c :: k -> Constraint) (t :: TyForest k) where ... Source #
a constraint holds for all elements in the forest
Equations
AllForest (c :: k -> Constraint) (xs :: TyForest k) = All (AllTreeC c) xs |
helpers for witnessing the constraints
allTopHTree :: forall {k} (f :: k -> Type) (t :: TyTree k). HTree f t -> Dict (AllTree (Top :: k -> Constraint) t) Source #
witnesses that for any HTree the constraint AllTree Top always holds
allTopHForest :: forall {k} (f :: k -> Type) (t :: TyForest k). HForest f t -> Dict (AllForest (Top :: k -> Constraint) t) Source #
witnesses that for any HForest the constraint AllForest Top always holds