Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Idx i f a = (Ixed (f (Cofree f a)), IxValue (f (Cofree f a)) ~ Cofree f a, Index (f (Cofree f a)) ~ i)
- data Zipper i (f :: * -> *) a = Zipper {}
- currentIndex :: Zipper i f a -> Maybe i
- currentPath :: Zipper i f a -> [i]
- focus_ :: Lens' (Zipper i f a) a
- unwrapped_ :: Lens' (Zipper i f a) (Cofree f a)
- tug :: (a -> Maybe a) -> a -> a
- zipper :: Cofree f a -> Zipper i f a
- fromRecursive :: Recursive t => t -> Zipper i (Base t) ()
- tagged :: Recursive t => (t -> a) -> t -> Zipper i (Base t) a
- down :: Idx i f a => i -> Zipper i f a -> Maybe (Zipper i f a)
- up :: Idx i f a => Zipper i f a -> Maybe (Zipper i f a)
- rezip :: Idx i f a => Zipper i f a -> Cofree f a
- flatten :: (Corecursive f, Idx i (Base f) a) => Zipper i (Base f) a -> f
- sibling :: Idx i f a => i -> Zipper i f a -> Maybe (Zipper i f a)
- children_ :: Traversable f => Traversal' (Zipper i f a) (Cofree f a)
- ichildren_ :: TraversableWithIndex i f => IndexedTraversal' i (Zipper i f a) (Cofree f a)
- branches :: Zipper i f a -> f (Cofree f a)
- branches_ :: Lens' (Zipper i f a) (f (Cofree f a))
- fold :: (Functor f, Idx i f a) => (a -> f r -> r) -> Zipper i f a -> r
Documentation
type Idx i f a = (Ixed (f (Cofree f a)), IxValue (f (Cofree f a)) ~ Cofree f a, Index (f (Cofree f a)) ~ i) Source #
Alias for constraints required for many zipper operations.
data Zipper i (f :: * -> *) a Source #
The core zipper type
Instances
Functor f => Functor (Zipper i f) Source # | |
(Eq1 f, Eq i, Eq a) => Eq (Zipper i f a) Source # | |
(Ord1 f, Ord i, Ord a) => Ord (Zipper i f a) Source # | |
Defined in Zipper.Recursive.Internal |
currentIndex :: Zipper i f a -> Maybe i Source #
Get the location of the current selection within its parent if we have one.
O(1)
currentPath :: Zipper i f a -> [i] Source #
Get the path to the current value from the root of the structure.
@O(depth)
unwrapped_ :: Lens' (Zipper i f a) (Cofree f a) Source #
Focus the currently selected sub-tree as a Cofree
tug :: (a -> Maybe a) -> a -> a Source #
A useful combinator for chaining operations which might fail. If an operation fails, the original zipper is returned.
E.g.
>>>
tug up z
fromRecursive :: Recursive t => t -> Zipper i (Base t) () Source #
Create a zipper from a recursive type, tagging it with ()
tagged :: Recursive t => (t -> a) -> t -> Zipper i (Base t) a Source #
Create a zipper from a recursive type, given a function to generate annotations.
down :: Idx i f a => i -> Zipper i f a -> Maybe (Zipper i f a) Source #
Select the subtree at the given location.
O(1)
up :: Idx i f a => Zipper i f a -> Maybe (Zipper i f a) Source #
Select the parent of the current location.
O(1)
flatten :: (Corecursive f, Idx i (Base f) a) => Zipper i (Base f) a -> f Source #
Rezip, forget all tags, and flatten the structure.
O(d)
sibling :: Idx i f a => i -> Zipper i f a -> Maybe (Zipper i f a) Source #
Move to the sibling which is located at i
in its parent.
O(1)
sibling i = up >=> down i
children_ :: Traversable f => Traversal' (Zipper i f a) (Cofree f a) Source #
Traversal over all subtrees of the current location.
ichildren_ :: TraversableWithIndex i f => IndexedTraversal' i (Zipper i f a) (Cofree f a) Source #
Indexed traversal over all subtrees of the current location.
branches :: Zipper i f a -> f (Cofree f a) Source #
Get the base-functor at the current location.
O(1)