The interface for arrows as conditionals.
Requires list arrows because False is represented as empty list, True as none empty lists.
Methods
ifA :: a b c -> a b d -> a b d -> a b dif lifted to arrows
ifP :: (b -> Bool) -> a b d -> a b d -> a b dshortcut:
ifP p = ifA (isA p)neg :: a b c -> a b bnegation:
neg f = ifA f none thiswhen :: a b b -> a b c -> a b bf `when` g: when the predicate g holds, f is applied, else the identity filter thiswhenP :: a b b -> (b -> Bool) -> a b bshortcut:
f `whenP` p = f `when` (isA p)whenNot :: a b b -> a b c -> a b bf `whenNot` g: when the predicate g does not hold, f is applied, else the identity filter thiswhenNotP :: a b b -> (b -> Bool) -> a b blike whenP
guards :: a b c -> a b d -> a b dg `guards` f: when the predicate g holds, f is applied, else noneguardsP :: (b -> Bool) -> a b d -> a b dlike whenP
filterA :: a b c -> a b bshortcut for
f guards thiscontaining :: a b c -> a c d -> a b cf `containing` g: keep only those results from f for which g holdsdefinition:
f `containing` g = f >>> g `guards` thisnotContaining :: a b c -> a c d -> a b cf `notContaining` g: keep only those results from f for which g does not holddefinition:
f `notContaining` g = f >>> ifA g none thisorElse :: a b c -> a b c -> a b cf `orElse` g: directional choice: if f succeeds, the result of f is the result, else g is appliedchoiceA :: [IfThen (a b c) (a b d)] -> a b dtagA :: a b c -> a b (Either b b)tag a value with Left or Right, if arrow has success, input is tagged with Left, else with Right
spanA :: a b b -> a [b] ([b], [b])split a list value with an arrow and returns a pair of lists. This is the arrow version of span. The arrow is deterministic.
example:
runLA (spanA (isA (/= '-'))) "abc-def"gives[("abc","-def")]as resultpartitionA :: a b b -> a [b] ([b], [b])partition a list of values into a pair of lists
This is the arrow Version of partition