on package:rio
on b u x y runs the binary function
b
on the results of applying unary function
u to two
arguments
x and
y. From the opposite perspective, it
transforms two inputs and combines the outputs.
((+) `on` f) x y = f x + f y
Typical usage:
sortBy (compare `on`
fst).
Algebraic properties:
(*) `on` id = (*) -- (if (*) ∉ {⊥, const
⊥})
((*) `on` f) `on` g = (*) `on` (f . g)
flip on f . flip on g = flip on (g .
f)
Configuration for how to create a
LogFunc. Intended to be used
with the
withLogFunc function.
A contramap. Use this to wrap sub-loggers via
mapRIO.
If you are on base > 4.12.0, you can just use
contramap.
What color is the log func configured to use for secondary content?
Intended for use by code which wants to optionally add additional
color to its log messages.
Create a
LogOptions value from the given
Handle and
whether to perform verbose logging or not. Individiual settings can be
overridden using appropriate
set functions. Logging output is
guaranteed to be non-interleaved only for a UTF-8
Handle in a
multi-thread environment.
When Verbose Flag is
True, the following happens:
- setLogVerboseFormat is called with True
- setLogUseColor is called with True (except on
Windows)
- setLogUseLoc is called with True
- setLogUseTime is called with True
- setLogMinLevel is called with Debug log
level
Create a
LogOptions value which will store its data in memory.
This is primarily intended for testing purposes. This will return both
a
LogOptions value and an
IORef containing the resulting
Builder value.
This will default to non-verbose settings and assume there is a
terminal attached. These assumptions can be overridden using the
appropriate
set functions.
This will print out the given message with a newline and disable any
further stickiness of the line until a new call to
logSticky
happens.
ANSI color codes for secondary content in the log output.
Default: "\ESC[90m" -- Bright black (gray)
O(n) Concatenate a list of ByteStrings.
Map a function over a
ByteString and concatenate the results
O(n) cons is analogous to (:) for lists, but of
different complexity, as it requires making a copy.
O(n) The
partition function takes a predicate a
ByteString and returns the pair of ByteStrings with elements which do
and do not satisfy the predicate, respectively; i.e.,
partition p bs == (filter p xs, filter (not . p) xs)
O(1) Extract the head and tail of a ByteString, returning
Nothing if it is empty.
O(1) cons is analogous to
(:) for lists.
O(1) Unlike
cons,
cons' is strict in the
ByteString that we are consing onto. More precisely, it forces the
head and the first chunk. It does this because, for space efficiency,
it may coalesce the new byte onto the first 'chunk' rather than
starting a new 'chunk'.
So that means you can't use a lazy recursive contruction like this:
let xs = cons' c xs in xs
You can however use
cons, as well as
repeat and
cycle, to build infinite lazy ByteStrings.