Data.Record.Field.Indexable
Description
Composition operators for collection fields.
Documentation
class Indexable a i whereSource
Class of collection types that can be indexed into.
TODO: This should probably be a single-parameter type class with two associated types instead.
(#!) :: (Field a, Indexable (Dst a) i) => a -> i -> Src a :-> Maybe (Element (Dst a))Source
Compose a field with an collection safely.
Indexable
r .# coll #! idx
returns Nothing if idx was not found from the collection, and
Just v if v was found.
r .# coll #! idx =: Just v
sets the value at idx in the collection to be v. If the value
wasn't in the collection, it's inserted. The exact semantics of
insertion depend on the actual collection in question.
r .# coll #! idx =: Nothing
removes the value at idx from the collection, if possible.