% package:percent-format
Formats a single value into a string without finalizing: leaving
duplicate percent signs & remaining format sequences.
> "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.
Smart-constructor for Quotients
Formats two values into a string without finalizing: leaving duplicate
percent signs & remaining format sequences.
> "%s %s!" %% ("Hello","World")
"Hello World!"
> "load avg: %.2f %.2f %.2f" %% (0.666,0.333)
"load avg: %0.67 %0.33 %.2f"
In general:
s %% (x,y) == s % x % y
Please use
-%% if you don't intend to format values into a
string any further.
Formats three values into a string without finalizing.
> "load avg: %.2f %.2f %.2f" %%% (0.666,0.333,0.1)
"load avg: %0.67 %0.33 %0.10"
Formats four values into a string without finalizing.
Formats five values into a string without finalizing.
(%%%%%%) :: (Show a, Show b, Show c, Show d, Show e, Show f) => String -> (a, b, c, d, e, f) -> String Formats six values into a string without finalizing.
Just an alias to
% for use whenever
Data.Ratio is in
scope.
import Data.Ratio
import Text.PercentFormat hiding ((%))
"..." +% 1 -% 2
Formats the last value into a string. This finalizes formatting,
removing duplicate percent signs and replacing remaining format
sequences with interrogation marks.
> "Hello %s!" -% "World"
"Hello World!"
> "processor usage: %d%%" -% 67
"processor usage: 67%"
> "load avg: %.2f %.2f %.2f" % 0.666
"load avg: %0.67 ? ?"
Please use
% if you intend to further format values (chaining).
Formats two values into a string and finalizes it: removing duplicate
percent signs & replacing remaining format sequences with
interrogation marks.
> "%s %s!" -%% ("Hello","World")
"Hello World!"
> "load avg: %.2f %.2f %.2f" -%% (0.666,0.333)
"load avg: %0.67 %0.33 ?"
In general:
s -%% (x,y) == s % x -% y
Please use
%% if you intend to further format values.
Formats three values into a string and finalizes it.
> "load avg: %.2f %.2f %.2f" -%%% (0.666,0.333,0.1)
"load avg: %0.67 %0.33 %0.10"
Formats four values into a string and finalizes it.
Formats five values into a string and finalizes it.
(-%%%%%%) :: (Show a, Show b, Show c, Show d, Show e, Show f) => String -> (a, b, c, d, e, f) -> String Formats six values into a stirng and finalizes it.
Replaces "%%" by "%". Any remaining occurrences of format strings are
replaced by the given error character. Field width is respected when
possible.
> "100%% %i" /% '?'
"100% ?"
> "100%% %03i" /% '?'
"100% ???"