-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Combinators to write Show instances
--   
--   A minimal pretty-printing library for Show instances in Haskell.
@package show-combinators
@version 0.2.0.0


-- | Combinators to write <a>Show</a> instances.
--   
--   The following type illustrates the common use cases.
--   
--   <pre>
--   data MyType a
--     = C a a                   -- a regular constructor
--     | a :+: a                 -- an infix constructor
--     | R { f1 :: a, f2 :: a }  -- a record
--   
--   infixl 4 :+:
--   
--   instance <a>Show</a> a =&gt; <a>Show</a> (MyType a) where
--     <a>showsPrec</a> = <a>flip</a> precShows where
--       precShows (C a b) = <a>showCon</a> "C" <a>@|</a> a <a>@|</a> b
--       precShows (c :+: d) = <a>showInfix'</a> ":+:" 4 c d
--       precShows (R {f1 = e, f2 = f}) =
--         <a>showRecord</a> "R" ("f1" <a>.=.</a> e <a>&amp;|</a> "f2" <a>.=.</a> f)
--   </pre>
module Text.Show.Combinators
class Show a
showsPrec :: Show a => Int -> a -> ShowS
show :: Show a => a -> String
showList :: Show a => [a] -> ShowS
type ShowS = String -> String
showString :: String -> ShowS
showParen :: Bool -> ShowS -> ShowS
showChar :: Char -> ShowS
shows :: Show a => a -> ShowS
showListWith :: (a -> ShowS) -> [a] -> ShowS

-- | Type of strings representing expressions, parameterized by the
--   surrounding precedence level.
--   
--   This is the return type of <tt><a>flip</a> <a>showsPrec</a></tt>.
type PrecShowS = Int -> ShowS

-- | Show a constructor.
--   
--   Possible constructor names are:
--   
--   <ul>
--   <li>regular constructors (e.g., <tt>"Left"</tt>);</li>
--   <li>parenthesized infix constructors (e.g., <tt>"(:)"</tt>);</li>
--   <li>smart constructors, for abstract types (e.g.,
--   <tt>"Map.fromList"</tt>).</li>
--   </ul>
--   
--   <h3><b>Example with smart constructor</b></h3>
--   
--   <pre>
--   instance (Show k, Show v) =&gt; Show (Map k v) where
--     showsPrec = <a>flip</a> precShows where
--       precShows m = <a>showCon</a> "Map.fromList" <a>@|</a> Map.toList m
--   
--   -- Example output:
--   -- &gt; Map.fromList [(33, True), (55, False)]
--   </pre>
showCon :: String -> PrecShowS

-- | Show a function application.
showApp :: PrecShowS -> PrecShowS -> PrecShowS
infixl 2 `showApp`

-- | Show a function application.
--   
--   This is an infix shorthand for <a>showApp</a> when the argument type
--   is an instance of <a>Show</a>.
--   
--   <pre>
--   showF @| x = showApp showF (flip showsPrec x)
--   </pre>
(@|) :: Show a => PrecShowS -> a -> PrecShowS
infixl 2 @|

-- | Show an applied infix operator with a given precedence.
showInfix :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS

-- | Show an applied infix operator with a given precedence.
--   
--   This is a shorthand for <a>showInfix</a> when the arguments types are
--   instances of <a>Show</a>.
--   
--   <pre>
--   showInfix' op prec x y =
--     showInfix op prec (flip showsPrec x) (flip showsPrec y)
--   </pre>
showInfix' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS

-- | Show an applied infix operator which is left associative
--   (<tt>infixl</tt>). Use with care.
--   
--   <h4>Warning</h4>
--   
--   This combinator assumes that, if there is another infix operator to
--   the left, it is either left associative with the same precedence, or
--   it has a different precedence. An expression containing two operators
--   at the same level with different associativities is ambiguous and will
--   not be shown correctly with <a>showInfixl</a> and <a>showInfixr</a>.
--   
--   By default, prefer <a>showInfix</a> and <a>showInfix'</a>.
showInfixl :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS

-- | Show an applied infix operator which is left associative
--   (<tt>infixl</tt>). Use with care, see <a>showInfixl</a>.
--   
--   This is a shorthand for <a>showInfixl</a> when the arguments types are
--   instances of <a>Show</a>.
--   
--   By default, prefer <a>showInfix</a> and <a>showInfix'</a>.
showInfixl' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS

-- | Show an applied infix operator which is right associative
--   (<tt>infixr</tt>). Use with care.
--   
--   <h4>Warning</h4>
--   
--   This combinator assumes that, if there is another infix operator to
--   the right, it is either right associative with the same precedence, or
--   it has a different precedence. An expression containing two operators
--   at the same level with different associativities is ambiguous and will
--   not be shown correctly with <a>showInfixl</a> and <a>showInfixr</a>.
--   
--   By default, prefer <a>showInfix</a> and <a>showInfix'</a>.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   showList :: Show a =&gt; [a] -&gt; PrecShowS
--   showList [] = showCon "[]"
--   showList (x : xs) = showInfixr ":" 5 (flip showsPrec x) (showList xs)
--   
--   -- Example output:
--   -- &gt; 0 : 1 : 2 : 3 : []
--   </pre>
showInfixr :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS

-- | Show an applied infix operator which is right associative
--   (<tt>infixr</tt>). Use with care, see <a>showInfixr</a>.
--   
--   This is a shorthand for <a>showInfixr</a> when the arguments types are
--   instances of <a>Show</a>.
--   
--   By default, prefer <a>showInfix</a> and <a>showInfix'</a>.
showInfixr' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS

-- | Strings representing a set of record fields separated by commas. They
--   can be constructed using (<a>.=.</a>) and (<a>@|</a>), or using
--   <a>showField</a> and <a>appendFields</a>.
type ShowFields = ShowS

-- | Show a record. The first argument is the constructor name. The second
--   represents the set of record fields.
showRecord :: String -> ShowFields -> PrecShowS

-- | Show a single record field: a field name and a value separated by
--   <tt>'='</tt>.
showField :: String -> PrecShowS -> ShowFields

-- | Show a single record field: a field name and a value separated by
--   <tt>'='</tt>.
--   
--   This is an infix shorthand for <a>showField</a> when the value type is
--   an instance of <a>Show</a>.
--   
--   <pre>
--   field .=. x   =   showField field (flip showsPrec x)
--   </pre>
(.=.) :: Show a => String -> a -> ShowFields
infixr 8 .=.

-- | Empty set of record fields.
noFields :: ShowFields

-- | Separate two <b>nonempty</b> sets of record fields by a comma.
appendFields :: ShowFields -> ShowFields -> ShowFields
infixr 1 `appendFields`

-- | An infix synonym of <a>appendFields</a>.
(&|) :: ShowFields -> ShowFields -> ShowFields
infixr 1 &|
