The adapt Primitive
adapt lens from back refine
Section titled “adapt lens from back refine”The sole primitive everything composes from.
Parameters:
lens— inner lens to apply to the focused valuefrom— extract inner source from outer (must return Either)back— write inner result back into outer staterefine— transform the focused value (must return Either)
Returns: A lens with get and set operations.
adapt identity (s: s.x) (s: v: s // { x = v; }) (v: bend.right (v + 1))How it works:
get extracts via from, applies lens.get, then applies refine.
set extracts via from, applies lens.set, writes back via back.
All other combinators in Bend — pipe, record, each, alt, attr — are built from adapt.