Common lenses/prisms/optionals that most projects will use.
Convenient infix operator for composing optionals.
.getOption (maybe => array 2) (Just <| Array.fromList [ 10, 11, 12, 13 ])
12
Step into a Maybe value.
maybe.set 5 Nothing
> Just 5Step into an Array at the given index.
.getOption (array 2) (Array.fromList [ 10, 11, 12, 13 ])
> Just 12
.getOption (array 8) (Array.fromList [ 10, 11, 12, 13 ])
> NothingStep into a Dict with the given key.
.getOption (dict "Tom") (Dict.fromList [ ( "Tom", "Cat" ) ])
> Just "Cat"
.getOption (dict "Jerry") (Dict.fromList [ ( "Tom", "Cat" ) ])
> NothingStep into the success value of a Result.
result.getOption (Ok 5)
> Just 5
result.getOption (Err "500")
> NothingStep into a record with an id key.
id.get { id = 1000, name = ... }
> Just 1000Since records with an id field are incredible common, this is
included for convenience. It also serves as a simple recipe for
creating record lenses.
Step into the first element of a pair.
first.get ( 'a', 'b' )
> Just 'a'Step into the second element of a pair.
second.get ( 'a', 'b' )
> Just 'b'
Convenient Infix operator for composing lenses. Allows to chain lens composition for deeply nested structures: