. -package:aeson

Right to left function composition.
(f . g) x = f (g x)
f . id = f = id . f

Examples

>>> map ((*2) . length) [[], [0, 1, 2], [0]]
[0,6,2]
>>> foldr (.) id [(+1), (*3), (^3)] 2
25
>>> let (...) = (.).(.) in ((*2)...(+)) 5 10
30
Morphism composition. Implementations should satisfy the law:
  • Associativity f . (g . h) = (f . g) . h
This means that the way morphisms are grouped is irrelevant, so it is unambiguous to write a composition of morphisms as f . g . h, without parentheses.
Function composition.
morphism composition
morphism composition
Function composition.
Bijection composition
morphism composition
Strict variant of function composition. Defined as:
(f . g) x = f $! g $! x
Internally used since version 0.10.0.0. Moved to Data.Function.Between.Strict.Internal module and exposed in version 0.11.0.0.
Bitwise "and"
Infix version of shiftL.
Infix version of shiftR.
Infix version of xor.
Bitwise "or"
Conjunction: p1 .&&. p2 passes if both p1 and p2 pass.
Nondeterministic choice: p1 .&. p2 picks randomly one of p1 and p2 to test. If you test the property 100 times it makes 100 random choices.
Disjunction: p1 .||. p2 passes unless p1 and p2 simultaneously fail.
Compose a non-indexed function with an Indexed function. Mnemonically, the > points to the indexing we want to preserve. This is the same as (.). f . g (and f .> g) gives you the index of g unless g is index-preserving, like a Prism, Iso or Equality, in which case it'll pass through the index of f.
>>> let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]

>>> nestedMap^..(itraversed.>itraversed).withIndex
[(10,"one,ten"),(20,"one,twenty"),(30,"two,thirty"),(40,"two,forty")]
Replace the target of a Lens or all of the targets of a Setter or Traversal in our monadic state with a new value, irrespective of the old. This is an infix version of assign.
>>> execState (do _1 .= c; _2 .= d) (a,b)
(c,d)
>>> execState (both .= c) (a,b)
(c,c)
(.=) :: MonadState s m => Iso' s a       -> a -> m ()
(.=) :: MonadState s m => Lens' s a      -> a -> m ()
(.=) :: MonadState s m => Traversal' s a -> a -> m ()
(.=) :: MonadState s m => Setter' s a    -> a -> m ()
It puts the state in the monad or it gets the hose again.
Replace every target in the current state of an IndexedSetter, IndexedLens or IndexedTraversal with access to the index. When you do not need access to the index then (.=) is more liberal in what it can accept.
l .= b ≡ l .@= const b
(.@=) :: MonadState s m => IndexedSetter i s s a b    -> (i -> b) -> m ()
(.@=) :: MonadState s m => IndexedLens i s s a b      -> (i -> b) -> m ()
(.@=) :: MonadState s m => IndexedTraversal i s t a b -> (i -> b) -> m ()
Replace every target of an IndexedSetter, IndexedLens or IndexedTraversal with access to the index.
(.@~) ≡ iset
When you do not need access to the index then (.~) is more liberal in what it can accept.
l .~ b ≡ l .@~ const b
(.@~) :: IndexedSetter i s t a b    -> (i -> b) -> s -> t
(.@~) :: IndexedLens i s t a b      -> (i -> b) -> s -> t
(.@~) :: IndexedTraversal i s t a b -> (i -> b) -> s -> t
Replace the target of a Lens or all of the targets of a Setter or Traversal with a constant value. This is an infix version of set, provided for consistency with (.=).
f <$ a ≡ mapped .~ f $ a
>>> (a,b,c,d) & _4 .~ e
(a,b,c,e)
>>> (42,"world") & _1 .~ "hello"
("hello","world")
>>> (a,b) & both .~ c
(c,c)
(.~) :: Setter s t a b    -> b -> s -> t
(.~) :: Iso s t a b       -> b -> s -> t
(.~) :: Lens s t a b      -> b -> s -> t
(.~) :: Traversal s t a b -> b -> s -> t