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


-- | Easy and type-safe format strings for parsing and printing
--   
--   A lightweight library for one-off parsing and printing.
--   
--   See README.
@package scanf
@version 0.1.0.0

module Text.Scanf.Internal

-- | A pretty pair type to build lists with values of different types.
--   Remember to close lists with <tt>()</tt>.
--   
--   <pre>
--   3 <a>:+</a> "14" <a>:+</a> () :: <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ()
--   </pre>
data a :+ b
(:+) :: a -> b -> (:+) a b
infixr 1 :+
infixr 1 :+

-- | Typed <tt><a>scanf</a></tt>/<tt><a>printf</a></tt> format strings.
--   They can be built using the <a>fmt</a> quasiquote or with the
--   <a>fmt_</a> function and format combinators.
data Format t
[Empty] :: Format ()
[Constant] :: String -> Format t -> Format t
[Whitespace] :: String -> Format t -> Format t
[Readable] :: (Read a, Show a) => Format t -> Format (a :+ t)
[String] :: Format t -> Format (String :+ t)
[Char] :: Format t -> Format (Char :+ t)
emptyFmt :: Format ()

-- | Construct a format string. This is an alternative to <a>fmt</a> that
--   doesn't rely on Template Haskell.
--   
--   The components of a format string are composed using
--   <tt>(<a>.</a>)</tt> (function composition) and <tt>(<a>%</a>)</tt>
--   (wrapper for constant strings).
--   
--   <pre>
--   <a>fmt_</a> (<a>int</a> <a>.</a> " lazy " <a>%</a> <a>string</a> <a>.</a> " and " <a>%</a> <a>int</a> <a>.</a> " strict " <a>%</a> <a>string</a>)
--     :: <a>Format</a> (<a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ())
--   </pre>
fmt_ :: (Format () -> Format t) -> Format t

-- | Append a constant string to a format string component.
--   
--   N.B.: in <a>scanf</a>, spaces in the format string match any number of
--   whitespace character until the next nonspace character.
(%) :: String -> (Format t -> Format q) -> Format t -> Format q
infixr 9 %

-- | Append a constant string to a format string.
constant :: String -> Format t -> Format t

-- | Append a constant string with no whitespace to a format string.
constant' :: String -> Format t -> Format t

-- | Append a constant whitespace string to a format string.
whitespace :: String -> Format t -> Format t
readable :: (Read a, Show a) => Format t -> Format (a :+ t)

-- | Format an <a>Integer</a>.
integer :: Format t -> Format (Integer :+ t)

-- | Format an <a>Int</a>.
int :: Format t -> Format (Int :+ t)

-- | Format a <a>Double</a>.
double :: Format t -> Format (Double :+ t)

-- | Format a <a>Format</a>.
string :: Format t -> Format (String :+ t)

-- | Format a <a>Format</a>.
char :: Format t -> Format (Char :+ t)
readmap :: (a -> b) -> ReadS a -> ReadS b
readsFormat :: Format t -> ReadS t

-- | Parse a string according to a format string.
--   
--   <pre>
--   <a>scanf</a> [<a>fmt</a>|Hello %s|] "Hello world!" :: <a>Maybe</a> (<a>Format</a> <a>:+</a> ())
--     = ("world!" <a>:+</a> ())
--   </pre>
scanf :: Format t -> String -> Maybe t

-- | Print a string according to a format string.
--   
--   <pre>
--   <a>printf</a> [<a>fmt</a>|Hello %s|] ("everyone!" <a>:+</a> ())
--     = "Hello everyone!" 
--   </pre>
printf :: Format t -> t -> String
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a Text.Scanf.Internal.:+ b)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (a Text.Scanf.Internal.:+ b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a Text.Scanf.Internal.:+ b)
instance GHC.Show.Show (Text.Scanf.Internal.Format t)

module Text.Scanf.TH
formatString :: String -> Q Exp

-- | Parse a typed <a>Format</a> string.
--   
--   The following conversion strings are supported:
--   
--   <ul>
--   <li><tt>%d</tt>: signed integer (<a>Int</a>)</li>
--   <li><tt>%l</tt>: signed integer (<a>Integer</a>, unbounded)</li>
--   <li><tt>%f</tt>: floating point (<a>Double</a>)</li>
--   <li><tt>%s</tt>: string of non-space characters (<a>Format</a>)</li>
--   <li><tt>%c</tt>: single character (<a>Format</a>)</li>
--   <li><tt>%%</tt>: parse/print a literal percent character</li>
--   </ul>
--   
--   N.B.: in <a>scanf</a>, spaces in the format string match any number of
--   whitespace character until the next nonspace character.
--   
--   <pre>
--   [<a>fmt</a>|%d lazy %s and %d strict %s|]
--     :: <a>Format</a> (<a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ())
--   </pre>
fmt :: QuasiQuoter


-- | Dead simple and type-safe
--   <tt><a>scanf</a></tt>/<tt><a>printf</a></tt>.
module Text.Scanf

-- | Parse a string according to a format string.
--   
--   <pre>
--   <a>scanf</a> [<a>fmt</a>|Hello %s|] "Hello world!" :: <a>Maybe</a> (<a>Format</a> <a>:+</a> ())
--     = ("world!" <a>:+</a> ())
--   </pre>
scanf :: Format t -> String -> Maybe t

-- | Print a string according to a format string.
--   
--   <pre>
--   <a>printf</a> [<a>fmt</a>|Hello %s|] ("everyone!" <a>:+</a> ())
--     = "Hello everyone!" 
--   </pre>
printf :: Format t -> t -> String

-- | A pretty pair type to build lists with values of different types.
--   Remember to close lists with <tt>()</tt>.
--   
--   <pre>
--   3 <a>:+</a> "14" <a>:+</a> () :: <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ()
--   </pre>
data a :+ b
(:+) :: a -> b -> (:+) a b
infixr 1 :+
infixr 1 :+

-- | Parse a typed <a>Format</a> string.
--   
--   The following conversion strings are supported:
--   
--   <ul>
--   <li><tt>%d</tt>: signed integer (<a>Int</a>)</li>
--   <li><tt>%l</tt>: signed integer (<a>Integer</a>, unbounded)</li>
--   <li><tt>%f</tt>: floating point (<a>Double</a>)</li>
--   <li><tt>%s</tt>: string of non-space characters (<a>Format</a>)</li>
--   <li><tt>%c</tt>: single character (<a>Format</a>)</li>
--   <li><tt>%%</tt>: parse/print a literal percent character</li>
--   </ul>
--   
--   N.B.: in <a>scanf</a>, spaces in the format string match any number of
--   whitespace character until the next nonspace character.
--   
--   <pre>
--   [<a>fmt</a>|%d lazy %s and %d strict %s|]
--     :: <a>Format</a> (<a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ())
--   </pre>
fmt :: QuasiQuoter

-- | Construct a format string. This is an alternative to <a>fmt</a> that
--   doesn't rely on Template Haskell.
--   
--   The components of a format string are composed using
--   <tt>(<a>.</a>)</tt> (function composition) and <tt>(<a>%</a>)</tt>
--   (wrapper for constant strings).
--   
--   <pre>
--   <a>fmt_</a> (<a>int</a> <a>.</a> " lazy " <a>%</a> <a>string</a> <a>.</a> " and " <a>%</a> <a>int</a> <a>.</a> " strict " <a>%</a> <a>string</a>)
--     :: <a>Format</a> (<a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> <a>Int</a> <a>:+</a> <a>Format</a> <a>:+</a> ())
--   </pre>
fmt_ :: (Format () -> Format t) -> Format t

-- | Typed <tt><a>scanf</a></tt>/<tt><a>printf</a></tt> format strings.
--   They can be built using the <a>fmt</a> quasiquote or with the
--   <a>fmt_</a> function and format combinators.
data Format t

-- | Append a constant string to a format string component.
--   
--   N.B.: in <a>scanf</a>, spaces in the format string match any number of
--   whitespace character until the next nonspace character.
(%) :: String -> (Format t -> Format q) -> Format t -> Format q
infixr 9 %

-- | Format an <a>Integer</a>.
integer :: Format t -> Format (Integer :+ t)

-- | Format an <a>Int</a>.
int :: Format t -> Format (Int :+ t)

-- | Format a <a>Double</a>.
double :: Format t -> Format (Double :+ t)

-- | Format a <a>Format</a>.
string :: Format t -> Format (String :+ t)

-- | Format a <a>Format</a>.
char :: Format t -> Format (Char :+ t)
