| Copyright | (C) MLabs 2025 |
|---|---|
| License | Apache 2.0 |
| Maintainer | koz@mlabs.city, sean@mlabs.city |
| Safe Haskell | None |
| Language | Haskell2010 |
Covenant.Zipper
Contents
Description
A read-only zipper for the Covenant ASG, based on an action monad.
Since: 1.3.0
Synopsis
- data ZipperAction
- data Tape a b = Tape [a] b [a]
- data ZipperState where
- pattern WorkingZipper :: [Tape Ref Id] -> Tape Ref (Either Arg (Id, ASGNode)) -> ZipperState
- pattern BrokenZipper :: ZipperState
- data ASGZipper a
- moveUp :: ZipperAction
- moveDown :: ZipperAction
- moveLeft :: ZipperAction
- moveRight :: ZipperAction
- resetZipper :: ZipperAction
- runASGZipper :: ASG -> ASGZipper a -> a
Types
data ZipperAction Source #
A requested movement from the zipper. To build these, use dedicated smart
constructors in this module. You can 'chain together' ZipperAction using
the Semigroup instance.
Since: 1.3.0
Instances
| Monoid ZipperAction Source # | Since: 1.3.0 | ||||
Defined in Covenant.Zipper Methods mempty :: ZipperAction # mappend :: ZipperAction -> ZipperAction -> ZipperAction # mconcat :: [ZipperAction] -> ZipperAction # | |||||
| Semigroup ZipperAction Source # | Since: 1.3.0 | ||||
Defined in Covenant.Zipper Methods (<>) :: ZipperAction -> ZipperAction -> ZipperAction # sconcat :: NonEmpty ZipperAction -> ZipperAction # stimes :: Integral b => b -> ZipperAction -> ZipperAction # | |||||
| Action ZipperAction Source # | Since: 1.3.0 | ||||
Defined in Covenant.Zipper Associated Types
Methods act :: ZipperAction -> Endo (StateOf ZipperAction) Source # | |||||
| MonadUpdate ZipperAction ASGZipper Source # | Since: 1.3.0 | ||||
Defined in Covenant.Zipper Methods send :: ZipperAction -> ASGZipper (StateOf ZipperAction) Source # update :: ZipperAction -> ASGZipper () Source # | |||||
| type StateOf ZipperAction Source # | |||||
Defined in Covenant.Zipper | |||||
A 'list with a focus', which may be of a different type to the rest. The
first field is 'backwards', in that its first element is actually the
furthest from the focus. Thus, if we have Tape [3, 2, 1] "foo" [4, 5],
the 'list' actually looks like this:
[1, 2, 3, "foo", 4, 5]
but not like this:
[3, 2, 1, "foo", 4, 5]
Since: 1.3.0
Constructors
| Tape [a] b [a] |
data ZipperState where Source #
The current state of the zipper, including whether it's in a broken state or not, and if not in a broken state, the current position and the path taken to get here.
Since: 1.3.0
Bundled Patterns
| pattern WorkingZipper :: [Tape Ref Id] -> Tape Ref (Either Arg (Id, ASGNode)) -> ZipperState | Matches on a working zipper, giving access to a stack of Parent positions use Since: 1.3.0 |
| pattern BrokenZipper :: ZipperState | Matches on a zipper in a broken state. Since: 1.3.0 |
A 'zipper command monad', designed to traverse an ASG. Based on an action monad.
To perform zipper moves, use send together with a
ZipperAction. If you want to find out something about where we're standing,
use request, together with pattern matching on
ZipperState.
Since: 1.3.0
Instances
| Applicative ASGZipper Source # | Since: 1.3.0 |
| Functor ASGZipper Source # | Since: 1.3.0 |
| Monad ASGZipper Source # | Since: 1.3.0 |
| MonadUpdate ZipperAction ASGZipper Source # | Since: 1.3.0 |
Defined in Covenant.Zipper Methods send :: ZipperAction -> ASGZipper (StateOf ZipperAction) Source # update :: ZipperAction -> ASGZipper () Source # | |
Functions
Actions
moveUp :: ZipperAction Source #
Move towards the source of the ASG, 'back up' along the path taken to reach the current position. Will put the zipper in a broken state if used at the source node.
Since: 1.3.0
moveDown :: ZipperAction Source #
Move to the leftmost child of the current position. Will put the zipper in a broken state if used at a sink node.
Since: 1.3.0
moveLeft :: ZipperAction Source #
Move to the sibling immediately to the left of the current position. Will put the zipper in a broken state if used at a leftmost sibling.
Since: 1.3.0
moveRight :: ZipperAction Source #
Move to the sibling immediately to the right of the current position. Will put the zipper in a broken state if used at a rightmost sibling.
Since: 1.3.0
resetZipper :: ZipperAction Source #
If the zipper is currently in a broken state, reset it to the last position it was at before breaking. Otherwise, this does nothing.
Since: 1.3.0