Heimdell/elm-optics/2.1.0

NOTE: the latest version is 3.0.1

Optics.Basic

Some optics for basic types.

Maybe

just_ : Prism pr (Maybe a) (Maybe b) a b

Match (go into) Just constructor.

nothing_ : SimplePrism pr (Maybe a) ()

Match Nothing constructor.

Either

right_ : Prism pr (Either c a) (Either c b) a b

Match Right constructor.

left_ : Prism pr (Either a c) (Either b c) a b

Match Left constructor.

Filter

only : (a -> Bool) -> SimpleTraversal a a

Pluggable filter.

Prevents reading and update for all parts that do to satisfy the predicate.

List

each : Traversal (List a) (List b) a b

List fold/traversal.

nth : Int -> SimpleTraversal (List a) a

Nth element of the list.

drop : Int -> SimpleTraversal (List a) (List a)

Everything except first n elements of the list.

take : Int -> SimpleTraversal (List a) (List a)

First n elements of the list.

The implementation will traverse n elements twice, because I was lazy and didn't write List.splitAt manually.

And there is no standard one.

cons : Prism pr (List a) (List b) ( a, List a ) ( b, List b )

Match head/tail of a non-empty list.

nil : Prism pr (List a) (List a) () ()

Match end of a non-empty list.

tail : SimpleTraversal (List a) (List a)

List tail.

Array

every : Traversal (Array a) (Array b) a b

Array fold/traversal.

ith : Int -> SimpleTraversal (Array a) a

Nth element of the array.

Tuple

first : Lens n ( a, c ) ( b, c ) a b

First tuple element.

second : Lens n ( c, a ) ( c, b ) a b

Second tuple element.

Dict

atKey : comparable_k -> SimpleTraversal (Dict comparable_k v) v

Access to the dict element at given key.

Iso
pr
ls
(Dict comparable_k v)
(Dict comparable_l w)
(List ( comparable_k, v ))
(List ( comparable_l, w ))

Dict <-> List.

dictValues : Traversal (Dict comparable_k v) (Dict comparable_k w) v w

Traversal over values in the dictionary.