| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | GHC2021 | 
Data.HTree
Description
a module for useful reexports from the modules
Synopsis
- data HList f ts where
 - data HTree f t where
 - pattern HNodeL :: forall l a f ts. Functor f => f a -> HForest f ts -> HTree f ('TyNode (Labeled l a) ts)
 - data TyTree k where
 - type TyNodeL l a = 'TyNode (Labeled l a)
 - hmap :: forall {k} (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). (forall a. f a -> g a) -> HTree f t -> HTree g t
 - hcmap :: forall {k} (c :: k -> Constraint) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). AllTree c t => (forall a. c a => f a -> g a) -> HTree f t -> HTree g t
 - htraverse :: forall {k} (h :: Type -> Type) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). Applicative h => (forall a. f a -> h (g a)) -> HTree f t -> h (HTree g t)
 - hctraverse :: forall {k} (c :: k -> Constraint) (h :: Type -> Type) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). (AllTree c t, Applicative h) => (forall a. c a => f a -> h (g a)) -> HTree f t -> h (HTree g t)
 - hFoldMap :: forall {k} (f :: k -> Type) (t :: TyTree k) (b :: Type). Semigroup b => (forall a. f a -> b) -> HTree f t -> b
 - hcFoldMap :: forall {k} (c :: k -> Constraint) (f :: k -> Type) (t :: TyTree k) (b :: Type). (AllTree c t, Semigroup b) => (forall a. 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 where ...
 - type family FlattenForest f where ...
 - newtype Labeled l a = MkLabeled {
- unLabel :: a
 
 - class HasField (x :: k) r a | x r -> a where
- getField :: r -> a
 
 - getElem :: forall {proxy} strat l typ t f. (HasField' (strat :: SearchStrategy) (Labeled l typ) t, Functor f) => proxy strat -> HTree f t -> f typ
 - data Proxy (t :: k) = Proxy
 - type Type = TYPE LiftedRep
 - type Constraint = CONSTRAINT LiftedRep
 - type Dict c = Has (Charge c) Proxy ()
 - pattern Dict :: forall (c :: Constraint). forall. c => Dict c
 - withDict :: Dict c -> (c => r) -> r
 
lists
data HList f ts where Source #
A heterogeneous list
>>>"bla" `HCons` 23 `HCons` HNil :: HList Identity '[ String, Int ]HCons (Identity "bla") (HCons (Identity 23) HNil)
Constructors
| HCons :: forall f x xs. f x -> HList f xs -> HList f (x : xs) infixr 5 | |
| HNil :: forall f. HList f '[] | 
Bundled Patterns
| pattern (:::) :: forall f x xs. f x -> HList f xs -> HList f (x : xs) infixr 5 | pattern synonym for  
  | 
| pattern HSing :: forall f a. f a -> HList f '[a] | pattern that allows to construct a singleton HList 
  | 
Instances
| (forall x. Eq x => Eq (f x), Typeable f) => Eq (EList (Has (Both (Typeable :: Type -> Constraint) Eq) f)) Source # | |
| Eq (f k2) => Eq (EList (HasIs k2 f)) Source # | |
| (Show (f x), Show (HList f xs)) => Show (HList f (x ': xs)) Source # | |
| Show (HList f ('[] :: [k])) Source # | |
| (Eq (f x), Eq (HList f xs)) => Eq (HList f (x ': xs)) Source # | |
| Eq (HList f ('[] :: [k])) Source # | |
trees
a heterogeneous rose tree indexed by a TyTree
Bundled Patterns
| pattern HLeaf :: forall f a. forall. f a -> HTree f ('TyNode a '[]) | 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 # | |
| (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 # | |
pattern HNodeL :: forall l a f ts. Functor f => f a -> HForest f ts -> HTree f ('TyNode (Labeled l a) ts) infixr 4 Source #
a pattern that allows for direct construction and destruction of nodes with labels
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 # | |
type TyNodeL l a = 'TyNode (Labeled l a) infixr 4 Source #
a type syonym that allows for easy construction of TyTrees that have labeled nodes
mapping a tree
hmap :: forall {k} (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). (forall a. f a -> g a) -> HTree f t -> HTree g t Source #
map a function over an HTree
hcmap :: forall {k} (c :: k -> Constraint) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). AllTree c t => (forall a. c a => f a -> g a) -> HTree f t -> HTree g t Source #
map a function with a constraint over an HTree
traversing a tree
htraverse :: forall {k} (h :: Type -> Type) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). Applicative h => (forall a. f a -> h (g a)) -> HTree f t -> h (HTree g t) Source #
traverse a structure with a function
hctraverse :: forall {k} (c :: k -> Constraint) (h :: Type -> Type) (f :: k -> Type) (g :: k -> Type) (t :: TyTree k). (AllTree c t, Applicative h) => (forall a. 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 a tree
value level
hFoldMap :: forall {k} (f :: k -> Type) (t :: TyTree k) (b :: Type). Semigroup b => (forall a. 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} (c :: k -> Constraint) (f :: k -> Type) (t :: TyTree k) (b :: Type). (AllTree c t, Semigroup b) => (forall a. 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 where ... Source #
a type family that flattens a tree down to a list
Equations
| FlattenTree ('TyNode x xs) = x : FlattenForest xs | 
type family FlattenForest f where ... Source #
a type family that flattens a forest down to a list
Equations
| FlattenForest '[] = '[] | |
| FlattenForest (x : xs) = FlattenTree x ++ FlattenForest xs | 
searching a tree
a newtype that is labeled with some typelevel tag
Instances
| Foldable (Labeled l2) Source # | |
Defined in Data.HTree.Labeled Methods fold :: Monoid m => Labeled l2 m -> m # foldMap :: Monoid m => (a -> m) -> Labeled l2 a -> m # foldMap' :: Monoid m => (a -> m) -> Labeled l2 a -> m # foldr :: (a -> b -> b) -> b -> Labeled l2 a -> b # foldr' :: (a -> b -> b) -> b -> Labeled l2 a -> b # foldl :: (b -> a -> b) -> b -> Labeled l2 a -> b # foldl' :: (b -> a -> b) -> b -> Labeled l2 a -> b # foldr1 :: (a -> a -> a) -> Labeled l2 a -> a # foldl1 :: (a -> a -> a) -> Labeled l2 a -> a # toList :: Labeled l2 a -> [a] # null :: Labeled l2 a -> Bool # length :: Labeled l2 a -> Int # elem :: Eq a => a -> Labeled l2 a -> Bool # maximum :: Ord a => Labeled l2 a -> a # minimum :: Ord a => Labeled l2 a -> a #  | |
| Traversable (Labeled l2) Source # | |
Defined in Data.HTree.Labeled  | |
| Functor (Labeled l2) Source # | |
| Generic (Labeled l2 a) Source # | |
| Show a => Show (Labeled l2 a) Source # | |
| Eq a => Eq (Labeled l2 a) Source # | |
| Ord a => Ord (Labeled l2 a) Source # | |
Defined in Data.HTree.Labeled  | |
| type Rep (Labeled l2 a) Source # | |
Defined in Data.HTree.Labeled  | |
class HasField (x :: k) r a | x r -> a where #
Constraint representing the fact that the field x belongs to
 the record type r and has field type a.  This will be solved
 automatically, but manual instances may be provided as well.
getElem :: forall {proxy} strat l typ t f. (HasField' (strat :: SearchStrategy) (Labeled l typ) t, Functor f) => proxy strat -> HTree f t -> f typ Source #
searches a tree for an element and returns that element, specialised to Labeled and unwraps
>>>import Data.Functor.Identity>>>type T = TyNodeL "top" Int [ TyNodeL "inter" Int '[ TyNodeL "foo" Int '[]], TyNodeL "foo" Int '[]]>>>t :: HTree Identity T = 42 `HNodeL` HNodeL 4 (HNodeL 69 HNil `HCons` HNil) `HCons` HNodeL 67 HNil `HCons` HNil>>>getElem @'DFS @"foo" @Int Proxy tIdentity 69>>>getElem @'BFS @"foo" @Int Proxy tIdentity 67
useful reexports
Proxy is a type that holds no data, but has a phantom parameter of
 arbitrary type (or even kind). Its use is to provide type information, even
 though there is no value available of that type (or it may be too costly to
 create one).
Historically,  is a safer alternative to the
 Proxy :: Proxy a idiom.undefined :: a
>>>Proxy :: Proxy (Void, Int -> Int)Proxy
Proxy can even hold types of higher kinds,
>>>Proxy :: Proxy EitherProxy
>>>Proxy :: Proxy FunctorProxy
>>>Proxy :: Proxy complicatedStructureProxy
Constructors
| Proxy | 
Instances
| Generic1 (Proxy :: k -> Type) | |
| Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a #  | |
| Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
| Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0  | 
| Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
| Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
| Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
| MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0  | 
| Monoid (Proxy s) | Since: base-4.7.0.0  | 
| Semigroup (Proxy s) | Since: base-4.9.0.0  | 
| Bounded (Proxy t) | Since: base-4.7.0.0  | 
| Enum (Proxy s) | Since: base-4.7.0.0  | 
| Generic (Proxy t) | |
| Ix (Proxy s) | Since: base-4.7.0.0  | 
Defined in Data.Proxy  | |
| Read (Proxy t) | Since: base-4.7.0.0  | 
| Show (Proxy s) | Since: base-4.7.0.0  | 
| Eq (Proxy s) | Since: base-4.7.0.0  | 
| Ord (Proxy s) | Since: base-4.7.0.0  | 
| type Rep1 (Proxy :: k -> Type) | Since: base-4.6.0.0  | 
| type Rep (Proxy t) | Since: base-4.6.0.0  | 
type Constraint = CONSTRAINT LiftedRep #
The kind of lifted constraints