X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Text%2FPrintf.hs;h=ee0b51ce97466b33ccf9a01740b78bb8c940eed4;hb=f8218e0dc6d2f354f89c1b4c0cc63f61844004c1;hp=69bc7cda9e2cb89f655b34716391ec2de96ac959;hpb=9ecf132d64d35e5997c12286f509b2f8d7f2a7ef;p=ghc-base.git diff --git a/Text/Printf.hs b/Text/Printf.hs index 69bc7cd..ee0b51c 100644 --- a/Text/Printf.hs +++ b/Text/Printf.hs @@ -12,7 +12,10 @@ -- ----------------------------------------------------------------------------- -module Text.Printf(printf, hPrintf) where +module Text.Printf( + printf, hPrintf, + PrintfType, HPrintfType, PrintfArg, IsChar +) where import Prelude import Data.Array @@ -23,7 +26,7 @@ import System.IO ------------------- -- | Format a variable number of arguments with the C-style formatting string. --- The return value is either 'String' or @(IO a)@. +-- The return value is either 'String' or @('IO' a)@. -- -- The format string consists of ordinary characters and /conversion -- specifications/, which specify how to format one of the arguments @@ -54,13 +57,6 @@ import System.IO -- > e exponent format float Float, Double -- > s string String -- --- The @PrintfType@ class provides the variable argument magic for --- 'printf'. Its implementation is intentionally not visible from --- this module. The following argument types are supported: Char, String, --- Int, Integer, Float, Double. If you attempt to pass an argument of a --- different type to 'printf', then the compiler will report it as a --- missing instance of @PrintfArg@. --- -- Mismatch between the argument types and the format string will cause -- an exception to be thrown at runtime. -- @@ -77,14 +73,19 @@ printf :: (PrintfType r) => String -> r printf fmt = spr fmt [] -- | Similar to 'printf', except that output is via the specified --- 'Handle'. The return type is restricted to @(IO a)@. +-- 'Handle'. The return type is restricted to @('IO' a)@. hPrintf :: (HPrintfType r) => Handle -> String -> r hPrintf hdl fmt = hspr hdl fmt [] +-- |The 'PrintfType' class provides the variable argument magic for +-- 'printf'. Its implementation is intentionally not visible from +-- this module. If you attempt to pass an argument of a type which +-- is not an instance of this class to 'printf' or 'hPrintf', then +-- the compiler will report it as a missing instance of 'PrintfArg'. class PrintfType t where spr :: String -> [UPrintf] -> t --- | The @HPrintfType@ class provides the variable argument magic for +-- | The 'HPrintfType' class provides the variable argument magic for -- 'hPrintf'. Its implementation is intentionally not visible from -- this module. class HPrintfType t where