(f . g) x = f (g x)
f . id = f = id . f
>>> map ((*2) . length) [[], [0, 1, 2], [0]] [0,6,2]
>>> foldr (.) id [(+1), (*3), (^3)] 2 25
>>> let (...) = (.).(.) in ((*2)...(+)) 5 10 30
>>> let f = print <. negate <. recip <. succ >>> f 3 -0.25Or use it anywhere you would use (.). Note that (<.) and (.>) have the same precedence, so they cannot be used together.
>>> -- This doesn't work! >>> -- print <. succ .> recip .> negate
\ x -> (g <. f) x == g (f x)
\ x -> (h <. g <. f) x == h (g (f x))
(f .! g) x = f $! g xThis defines the composition for the sub-category of strict Haskell functions. If the Functor class were parameterized by the domain and codomain categories (e.g., a regular Functor f would be CFunctor (->) (->) f instead) then this would allow us to define functors CFunctor (->) (!->) f where fmap f . fmap g = fmap (f .! g).
(f . g) x = f $! g $! xInternally used since version 0.10.0.0. Moved to Data.Function.Between.Strict.Internal module and exposed in version 0.11.0.0.
>>> 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")]