Safe Haskell | Safe-Inferred |
---|
- tripBy :: (a -> Bool) -> SplitFunction a b -> [a] -> b
- revTripBy :: (a -> Bool) -> SplitFunction a b -> [a] -> b
- type SplitFunction a b = ([a] -> b, [a] -> a -> [a] -> b)
- addParens :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> OpenAp (h p) a
- addShortParens :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> h p a -> h p a
- forwardInfix :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> OpenAp (h p) a
- reverseInfix :: (Openable (h p), Hierarchy h p, Show (h p a)) => (h p a -> Bool) -> OpenAp (h p) a
List Splitting
tripBy :: (a -> Bool) -> SplitFunction a b -> [a] -> bSource
Split a list at the first element that matched the predicate.
If the element was not found, apply the SplitFunction
.
revTripBy :: (a -> Bool) -> SplitFunction a b -> [a] -> bSource
As tripBy
, but search from the end.
type SplitFunction a b = ([a] -> b, [a] -> a -> [a] -> b)Source
Transform a list based on the presence and location of an element.
The first function of the pair is applied when no element was found. Its parameter is the original list.
The second of the pair is applied with an element is found. Its parameters are (in order) the preceding elements, the found element, and the following elements.
Implicit Parenthesis
addParens :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> OpenAp (h p) aSource
Create a group around a found subnode and all following nodes. If no node was found, then there is no change.
E.g
(a b lambda x y z) ===> (a b (lambda x y z))
addShortParens :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> h p a -> h p aSource
Add parenthesis around a found subnode and at most one following node. Associates to the right. If no node was found, then there is no change.
E.g.
(++ ++ x) ===> (++(++(x)))
Simple Infixes
forwardInfix :: (Openable (h p), Hierarchy h p) => (h p a -> Bool) -> OpenAp (h p) aSource
Given an infix-detecting predicate, find the first matching subnode in the given node. Move the matching node to the front and wrap either side in new subnodes. If there is no matching subnode or either side is missing, the node is returned unchanged.
E.g.
(a b + c d + e f) ===> (+ (a b) (c d + e f))
reverseInfix :: (Openable (h p), Hierarchy h p, Show (h p a)) => (h p a -> Bool) -> OpenAp (h p) aSource
Given an infix-detecting predicate, find the last matching subnode in the given node. Move the matching node to the front and wrap either side in new subnodes. If there is no matching subnode or either side is missing, the node is returned unchanged.
(a b ** c d ** e f) ===> (** (a b ** c d) (e f))