Operators

Edward Kmett edited this page Aug 9, 2015 · 147 revisions

Operators

Combinator(s) w/ Result Stateful w/ Result Notes
Control.Lens (Getting)
view / ^. use View a single target, or fold multiple monoidal targets.
views uses View/fold after applying a function.
to Build a getter from a plain function.
Control.Lens (Setting)
set / .~ <.~ assign / .= <.= Replace target(s) with value. <<.~ and <<.= return the old value.
over / %~ <%~ %= <%= Replace target(s) by applying function. <<%~ and <<%= return the old value
setting , upon Build a setter from a map-like function.
id / %%~ / traverseOf %%= Update target(s) with an Applicative or auxiliary result.
Control.Lens.Fold / Control.Lens.Prism
review Choose a branch of a sum type
preview / ^? / firstOf Get the first target or Nothing if there are no targets.
previews preview after applying a function
toListOf / ^.. Return a list of the target(s)
Control.Lens (Getting Indexed)
iview / ^@. iuse View the index and value of an IndexedGetter or IndexedLens.
iviews iuses View a function of the index and value of an IndexedGetter into the current environment.
Control.Lens (Setting Indexed)
iset / .@~ .@= Set target(s) with access to the index.
iover / %@~ <%@~ %@= <%@= Update target(s) with access to the index.
withIndex, itraverseOf, %%@~ %%@= Update target(s) with an Applicative or auxiliary result with access to the index.
Control.Lens (math)
+~ <+~ += <+= Add to target(s)
-~ <-~ -= <-= Subtract from target(s)
*~ <*~ *= <*= Multiply target(s)
//~ <//~ //= <//= Divide target(s)
^~ <^~ ^= <^= Raise target(s) to a non-negative Integral power
^^~ <^^~ ^^= <^^= Raise target(s) to an Integral power
**~ <**~ **= <**= Raise target(s) to an arbitrary power
Control.Lens (logic)
||~ <||~ ||= <||= Logically or target(s)
&&~ <&&~ &&= <&&= Logically and target(s)
<>~ <<>~ <>= <<>= mappend to the target monoidal value(s)
Data.Bits.Lens
.|.~ <.|.~ .|.= <.|.= Bitwise or target(s)
.&.~ <.&.~ .&.= <.&.= Bitwise and target(s)
System.FilePath.Lens
</>~ <</>~ </>= <</>= Append a relative path to a FilePath
<.>~ <<.>~ <.>= <<.>= Append a file extension to a FilePath