5      !"#$%&'()*+,-./01234Safe 35>ILNYHandy type synonym for the things we're working with. You should regard a value of type  Format m a bF as something which explains how to write some element of the monoid mO (a "string" for our purposes), and which will change the type of printf from a to ba. For instance, something which adds a responsibility to provide an additional argument of type t might have type Format m a (t -> a)W, while a formatter which somehow absolves you of that responsibility would have type Format m (t -> a) a.nWe can apply this to something like putStrLn to get a function for formatted printing. Typically you'll have  r = IO (), but that needn't be the case.EIf you just want to build a string / element of your monoid, we have sprintf = printfWith idFormatter for a constant string. Note that for string literals, this is implicit if you turn on the OverloadedStrings extension.7let x = "world" in printfLn (c "Hello, " . c x . c "!") Hello, world!%Inclusion of a string as an argument.?mapM_ (printfLn ("Hello, " . i . "!")) ["Anne", "Bob", "world"] Hello, Anne! Hello, Bob! Hello, world!Given a way to turn a value of type t into a string, this builds a formatter which demands an additional argument of type t and splices it in.Splice in anything showable.[printfLn ("list: " . s . " tuple: " . s . " string: " . s) [1,2,3] ("hello", 'a') "there"4list: [1,2,3] tuple: ("hello",'a') string: "there"5Select which formatter to apply based on an argument.OprintfLn (bind (\b -> if b then eFloat Nothing else fFloat Nothing)) False 53285328.0NprintfLn (bind (\b -> if b then eFloat Nothing else fFloat Nothing)) True 53285.328e3-printfLn (bind (\f -> f Nothing)) eFloat 53285.328e3JApply a function to the output of a formatter, possibly changing its type.1printfLn (mapMonoid (map toUpper) hex) 0xcafe1234CAFE1234 TGeneralizes the string type that a formatter uses by applying fromString internally. Transform a numeric formatter which will be used to handle absolute values, applying the first given function to the string to be spliced when the argument is negative, and the second given function otherwise.LprintfLn (signedWith (\v -> mconcat ["(",v,")"]) id (fFloat (Just 2))) (-pi)(3.14)>printfLn (signedWith ("-"<>) ("+"<>) (padLeft "0" 5 s)) (-439)-00439<printfLn (signedWith ("-"<>) ("+"<>) (padLeft "0" 5 s)) 1278+01278 |Show an integral value using the given base, and using the provided function to determine how to display individual digits. &Show an integral value in hexadecimal.6printfLn (dup . s . " in hexadecimal is " . hex) 5196651966 in hexadecimal is cafe  Show an integral value in octal.NShow a floating point value in exponential format. (e.g. 2.45e2, -1.5e-3) If digs| is Nothing, the value is shown to full precision, if it is Just d then at most d digits after the decimal point are shown.SShow a floating point value in standard decimal format. (e.g. 245000, -0.0015) If digs| is Nothing, the value is shown to full precision, if it is Just d then at most d digits after the decimal point are shown.Show a floating point value using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise. If digs| is Nothing, the value is shown to full precision, if it is Just d then at most d digits after the decimal point are shown. We can use 5| from the Arrow instance for Cokleisli w to produce formatters that manipulate the stack without printing. That is, we have /arr :: (Monoid m) => (s -> s') -> Format m s s'HPush an argument onto the stack to be consumed by subsequent formatters.>Duplicate an argument on the stack, making it available twice.)Swap the next two arguments on the stack.$Skip the next argument on the stack.9Apply a function to the argument on the top of the stack.>Apply a binary function to the top two arguments on the stack.PprintfLn (dup . s . " plus " . swap . dup . s . " equals " . apply2 (+) . s) 4 64 plus 6 equals 10NprintfLn (arr (\k x y -> k x y (x+y)) . s . " plus " . s . " equals " . s) 4 64 plus 6 equals 10 6789:;   6SafeipadLeft s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the left. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width.kpadRight s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the right. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width."789:; Safe!ipadLeft s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the left. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width."kpadRight s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the right. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width. !""789:;  !" !" !"Safe'ipadLeft s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the left. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width.(kpadRight s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the right. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width.#$%&'("789:; #$%&'(#$%&'(#$%&'(Safe-ipadLeft s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the left. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width..kpadRight s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the right. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width.)*+,-."789:; )*+,-.)*+,-.)*+,-.Safe3ipadLeft s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the left. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width.4kpadRight s n f will transform the formatter f, ensuring that the output produced is at least length n by appending sufficiently many copies of s on the right. The string s should have length at least 1, otherwise this has no effect. In cases where s has length greater than 1, the last occurrence of s will be truncated as necessary to fit the necessary width./01234"789:; /01234/01234/01234<      !"# !"# !"# !"# !"#$%&'$()$(*$(+$(,$(-.categ_7Q8jv1Il9tfDRFqUm97bEpControl.Category.PrintfControl.Category.Printf.String#Control.Category.Printf.Text.Strict!Control.Category.Printf.Text.Lazy)Control.Category.Printf.ByteString.Strict'Control.Category.Printf.ByteString.LazyFormat printfWithsprintfci spliceWithsbind mapMonoidgeneralizeString signedWith intAtBasehexocteFloatfFloatgFloatpushdupswapskipapplyapply2printfprintfLnhPrintf hPrintfLnpadLeftpadRightbase Control.Arrowarr$fIsStringCokleisliControl.Category>>><<<.idCategory