Type Parsers & Predicates
Type Checkers
Section titled “Type Checkers”right when value is integer; left otherwise.
right when value is string; left otherwise.
right when value is bool; left otherwise.
right when value is list; left otherwise.
right when value is float; left otherwise.
number
Section titled “number”right when value is int or float; left otherwise.
Structured Validators
Section titled “Structured Validators”satisfy pred
Section titled “satisfy pred”right s when pred s is true; left s otherwise.
satisfyWith pred lens
Section titled “satisfyWith pred lens”right when pred passes; uses lens for value focus.
nonEmpty
Section titled “nonEmpty”right { head; tail; } when list is non-empty; left [] when empty.
bend.nonEmpty.get [ 1 2 3 ] # right { head = 1; tail = [ 2 3 ]; }bend.nonEmpty.get [ ] # left [ ]nonBlank
Section titled “nonBlank”right when string is non-empty; left when empty or not a string.
optional lens
Section titled “optional lens”Pass null as right null; apply lens to non-null values.
(bend.optional bend.str).get null # right null(bend.optional bend.str).get "hi" # right "hi"(bend.optional bend.str).get 42 # left 42Predicate Combinators
Section titled “Predicate Combinators”andP pred1 pred2
Section titled “andP pred1 pred2”Combine two predicates with AND.
orP pred1 pred2
Section titled “orP pred1 pred2”Combine two predicates with OR.
notP pred
Section titled “notP pred”Negate a predicate.
Transformations
Section titled “Transformations”map f lens
Section titled “map f lens”Apply pure function f to focused value (wraps result in right).