Common lenses/prisms/optionals that most projects will use.
Step into a Maybe value.
maybe.set 5 Nothing
> Just 5Step into an Array at the given index.
array.getOption 2 (Array.fromList [10..15])
> Just 12
array.getOption 8 (Array.fromList [10..15])
> NothingStep into a Dict with the given key.
dict.getOption "Tom" (Dict.fromList [("Tom","Cat")])
> Just "Cat"
dict.getOption "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 optionals.
.getOption (maybe => array 2) (Just [10..15])