format1 :: Format r (Text -> r) format1 = "Person's name is " % text
format2 :: Format r r format2 = ", "
format3 :: Format r (Int -> r) format3 = "age is " % hex
myFormat :: Format r (Text -> Int -> r) myFormat = format1 % format2 % format3Notice how the argument types of format1 and format3 are gathered into the type of myFormat. (This is actually the composition operator for Formats Category instance, but that is (at present) inconvenient to use with regular Prelude. So this function is provided as a convenience.)
> "Hello %s!" % "World" "Hello World!"
> "processor usage: %d%%" % 67 "processor usage: 67%%"
> "load avg: %.2f %.2f %.2f" % 0.666 "load avg: %0.67 %.2f %.2f"Please use -% when formatting the last value into a string so that duplicate percent signs are removed.
l %%@= f ≡ state (l %%@~ f)
(%%@=) :: MonadState s m => IndexedLens i s s a b -> (i -> a -> (r, b)) -> s -> m r (%%@=) :: (MonadState s m, Monoid r) => IndexedTraversal i s s a b -> (i -> a -> (r, b)) -> s -> m r
>>> execState (do _1 %= f;_2 %= g) (a,b) (f a,g b)
>>> execState (do both %= f) (a,b) (f a,f b)
(%=) :: MonadState s m => Iso' s a -> (a -> a) -> m () (%=) :: MonadState s m => Lens' s a -> (a -> a) -> m () (%=) :: MonadState s m => Traversal' s a -> (a -> a) -> m () (%=) :: MonadState s m => Setter' s a -> (a -> a) -> m ()
(%=) :: MonadState s m => ASetter s s a b -> (a -> b) -> m ()
l %= f ≡ l %@= const f
(%@=) :: MonadState s m => IndexedSetter i s s a b -> (i -> a -> b) -> m () (%@=) :: MonadState s m => IndexedLens i s s a b -> (i -> a -> b) -> m () (%@=) :: MonadState s m => IndexedTraversal i s t a b -> (i -> a -> b) -> m ()
(%@~) ≡ ioverWhen you do not need access to the index then (%~) is more liberal in what it can accept.
l %~ f ≡ l %@~ const f
(%@~) :: IndexedSetter i s t a b -> (i -> a -> b) -> s -> t (%@~) :: IndexedLens i s t a b -> (i -> a -> b) -> s -> t (%@~) :: IndexedTraversal i s t a b -> (i -> a -> b) -> s -> t