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


-- | Web interface for the hledger accounting tool
--   
--   This is hledger's web interface. It provides a more user-friendly and
--   collaborative UI than the command-line or curses-style interfaces.
--   
--   hledger is a cross-platform program for tracking money, time, or any
--   other commodity, using double-entry accounting and a simple, editable
--   file format. It is inspired by and largely compatible with ledger(1).
--   hledger provides command-line, curses and web interfaces, and aims to
--   be a reliable, practical tool for daily use.
@package hledger-web
@version 1.10


-- | Settings are centralized, as much as possible, into this file. This
--   includes database connection settings, static file locations, etc. In
--   addition, you can configure a number of different aspects of Yesod by
--   overriding methods in the Yesod typeclass. That instance is declared
--   in the Foundation.hs file.
module Hledger.Web.Settings
development :: Bool
production :: Bool
hledgerorgurl :: Text
manualurl :: Text

-- | The default IP address to listen on. May be overridden with --host.
defhost :: String

-- | The default TCP port to listen on. May be overridden with --port.
defport :: Int
defbaseurl :: String -> Int -> String

-- | The location of static files on your system. This is a file system
--   path. The default value works properly with your scaffolded site.
staticDir :: FilePath

-- | The base URL for your static files. As you can see by the default
--   value, this can simply be "static" appended to your application root.
--   A powerful optimization can be serving static files from a separate
--   domain name. This allows you to use a web server optimized for static
--   files, more easily set expires and cache values, and avoid possibly
--   costly transference of cookies on static files. For more information,
--   please see:
--   <a>http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain</a>
--   
--   If you change the resource pattern for StaticR in Foundation.hs, you
--   will have to make a corresponding change here.
--   
--   To see how this value is used, see urlRenderOverride in Foundation.hs
staticRoot :: AppConfig DefaultEnv Extra -> Text

-- | Settings for <a>widgetFile</a>, such as which template languages to
--   support and default Hamlet settings.
widgetFileSettings :: WidgetFileSettings
widgetFile :: String -> Q Exp
data Extra
Extra :: Text -> Maybe Text -> Maybe Text -> Extra
[extraCopyright] :: Extra -> Text

-- | Google Analytics
[extraAnalytics] :: Extra -> Maybe Text
[extraStaticRoot] :: Extra -> Maybe Text
parseExtra :: DefaultEnv -> Object -> Parser Extra
instance GHC.Show.Show Hledger.Web.Settings.Extra

module Hledger.Web.Settings.StaticFiles
staticSite :: IO Static
js_jquery_flot_symbol_js :: StaticRoute
js_bootstrap_datepicker_min_js :: StaticRoute
js_excanvas_min_js :: StaticRoute
js_jquery_flot_crosshair_min_js :: StaticRoute
js_jquery_flot_selection_js :: StaticRoute
js_jquery_flot_canvas_min_js :: StaticRoute
js_typeahead_bundle_min_js :: StaticRoute
js_typeahead_bundle_js :: StaticRoute
js_jquery_flot_min_js :: StaticRoute
js_jquery_flot_js :: StaticRoute
js_jquery_flot_tooltip_js :: StaticRoute
js_jquery_flot_time_min_js :: StaticRoute
js_jquery_flot_tooltip_min_js :: StaticRoute
js_jquery_flot_errorbars_js :: StaticRoute
js_bootstrap_js :: StaticRoute
js_jquery_flot_image_min_js :: StaticRoute
js_jquery_flot_resize_js :: StaticRoute
js_jquery_flot_fillbetween_min_js :: StaticRoute
js_jquery_flot_resize_min_js :: StaticRoute
js_jquery_flot_stack_min_js :: StaticRoute
js_jquery_flot_threshold_min_js :: StaticRoute
js_jquery_flot_navigate_js :: StaticRoute
js_jquery_flot_navigate_min_js :: StaticRoute
js_jquery_flot_image_js :: StaticRoute
js_jquery_flot_pie_js :: StaticRoute
js_jquery_hotkeys_js :: StaticRoute
js_jquery_flot_canvas_js :: StaticRoute
js_excanvas_js :: StaticRoute
js_jquery_url_js :: StaticRoute
js_jquery_js :: StaticRoute
js_jquery_flot_time_js :: StaticRoute
js_jquery_flot_categories_js :: StaticRoute
js_jquery_cookie_js :: StaticRoute
js_jquery_flot_categories_min_js :: StaticRoute
js_jquery_flot_errorbars_min_js :: StaticRoute
js_jquery_min_js :: StaticRoute
js_jquery_flot_stack_js :: StaticRoute
js_jquery_flot_crosshair_js :: StaticRoute
js_jquery_flot_selection_min_js :: StaticRoute
js_jquery_flot_pie_min_js :: StaticRoute
js_jquery_flot_threshold_js :: StaticRoute
js_jquery_flot_symbol_min_js :: StaticRoute
js_jquery_flot_fillbetween_js :: StaticRoute
js_bootstrap_min_js :: StaticRoute
css_bootstrap_css :: StaticRoute
css_bootstrap_theme_css_map :: StaticRoute
css_bootstrap_theme_min_css :: StaticRoute
css_bootstrap_datepicker_standalone_min_css :: StaticRoute
css_bootstrap_css_map :: StaticRoute
css_bootstrap_theme_css :: StaticRoute
css_bootstrap_min_css :: StaticRoute
fonts_glyphicons_halflings_regular_ttf :: StaticRoute
fonts_glyphicons_halflings_regular_eot :: StaticRoute
fonts_glyphicons_halflings_regular_woff :: StaticRoute
fonts_glyphicons_halflings_regular_svg :: StaticRoute
hledger_js :: StaticRoute
hledger_css :: StaticRoute

module Hledger.Web.WebOptions
progname :: String
version :: String
prognameandversion :: String
webflags :: [Flag [(String, String)]]
webmode :: Mode [(String, String)]
data WebOpts
WebOpts :: Bool -> String -> Int -> String -> Maybe String -> [Capability] -> Maybe (CI ByteString) -> CliOpts -> WebOpts
[serve_] :: WebOpts -> Bool
[host_] :: WebOpts -> String
[port_] :: WebOpts -> Int
[base_url_] :: WebOpts -> String
[file_url_] :: WebOpts -> Maybe String
[capabilities_] :: WebOpts -> [Capability]
[capabilitiesHeader_] :: WebOpts -> Maybe (CI ByteString)
[cliopts_] :: WebOpts -> CliOpts
defwebopts :: WebOpts
rawOptsToWebOpts :: RawOpts -> IO WebOpts
checkWebOpts :: WebOpts -> WebOpts
getHledgerWebOpts :: IO WebOpts
data Capability
CapView :: Capability
CapAdd :: Capability
CapManage :: Capability
capabilityFromText :: Text -> Either Text Capability
capabilityFromBS :: ByteString -> Either ByteString Capability
instance GHC.Show.Show Hledger.Web.WebOptions.WebOpts
instance GHC.Show.Show Hledger.Web.WebOptions.Capability
instance GHC.Enum.Enum Hledger.Web.WebOptions.Capability
instance GHC.Enum.Bounded Hledger.Web.WebOptions.Capability
instance GHC.Classes.Ord Hledger.Web.WebOptions.Capability
instance GHC.Classes.Eq Hledger.Web.WebOptions.Capability
instance Data.Default.Class.Default Hledger.Web.WebOptions.WebOpts

module Hledger.Web.Widget.AddForm
addForm :: (site ~ HandlerSite m, RenderMessage site FormMessage, MonadHandler m) => Journal -> Day -> Markup -> MForm m (FormResult Transaction, WidgetFor site ())
addModal :: (MonadWidget m, r ~ Route (HandlerSite m), m ~ WidgetFor (HandlerSite m), RenderMessage (HandlerSite m) FormMessage) => r -> Journal -> Day -> m ()

module Hledger.Web.Widget.Common
accountQuery :: AccountName -> Text
accountOnlyQuery :: AccountName -> Text

-- | Render a <a>BalanceReport</a> as html.
balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r

-- | Link to a topic in the manual.
helplink :: Text -> Text -> HtmlUrl r
mixedAmountAsHtml :: MixedAmount -> HtmlUrl a
fromFormSuccess :: Applicative m => m a -> FormResult a -> m a
writeValidJournal :: MonadHandler m => FilePath -> Text -> m (Either String ())
journalFile404 :: FilePath -> Journal -> HandlerFor m (FilePath, Text)


-- | Define the web application's foundation, in the usual Yesod style. See
--   a default Yesod app's comments for more details of each part.
module Hledger.Web.Foundation

-- | The site argument for your application. This can be a good place to
--   keep settings and values requiring initialization before your
--   application starts running, such as database connections. Every
--   handler will have access to the data present here.
data App
App :: AppConfig DefaultEnv Extra -> Static -> Manager -> WebOpts -> IORef Journal -> App
[settings] :: App -> AppConfig DefaultEnv Extra

-- | Settings for static file serving.
[getStatic] :: App -> Static
[httpManager] :: App -> Manager
[appOpts] :: App -> WebOpts
[appJournal] :: App -> IORef Journal
type Handler = HandlerFor App
type Widget = WidgetFor App ()
resourcesApp :: [ResourceTree String]

-- | A convenience alias.
type AppRoute = Route App
type Form x = Html -> MForm (HandlerFor App) (FormResult x, Widget)

-- | A bundle of data useful for hledger-web request handlers and
--   templates.
data ViewData
VD :: WebOpts -> Day -> Journal -> Text -> Query -> [QueryOpt] -> [Capability] -> ViewData

-- | the command-line options at startup
[opts] :: ViewData -> WebOpts

-- | today's date (for queries containing relative dates)
[today] :: ViewData -> Day

-- | the up-to-date parsed unfiltered journal
[j] :: ViewData -> Journal

-- | the current q parameter, the main query expression
[q] :: ViewData -> Text

-- | a query parsed from the q parameter
[m] :: ViewData -> Query

-- | query options parsed from the q parameter
[qopts] :: ViewData -> [QueryOpt]

-- | capabilities enabled for this request
[caps] :: ViewData -> [Capability]

-- | Gather data used by handlers and templates in the current request.
getViewData :: Handler ViewData

-- | Find out if the sidebar should be visible. Show it, unless there is a
--   showsidebar cookie set to "0", or a ?sidebar=0 query parameter.
shouldShowSidebar :: Handler Bool

-- | Update our copy of the journal if the file changed. If there is an
--   error while reloading, keep the old one and return the error, and set
--   a ui message.
getCurrentJournal :: IORef Journal -> CliOpts -> Day -> Handler (Journal, Maybe String)
instance GHC.Show.Show Hledger.Web.Foundation.ViewData
instance GHC.Read.Read (Yesod.Routes.Class.Route Hledger.Web.Foundation.App)
instance GHC.Classes.Eq (Yesod.Routes.Class.Route Hledger.Web.Foundation.App)
instance GHC.Show.Show (Yesod.Routes.Class.Route Hledger.Web.Foundation.App)
instance Yesod.Core.Class.Yesod.Yesod Hledger.Web.Foundation.App
instance Yesod.Routes.Class.ParseRoute Hledger.Web.Foundation.App
instance Yesod.Routes.Class.RenderRoute Hledger.Web.Foundation.App
instance Yesod.Routes.Class.RouteAttrs Hledger.Web.Foundation.App
instance Text.Shakespeare.I18N.RenderMessage Hledger.Web.Foundation.App Yesod.Form.Types.FormMessage
instance GHC.Show.Show Text.Blaze.Internal.Markup

module Hledger.Web.Import

-- | Append two lists, i.e.,
--   
--   <pre>
--   [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
--   [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
--   </pre>
--   
--   If the first list is not finite, the result is the first list.
(++) :: () => [a] -> [a] -> [a]
infixr 5 ++

-- | The value of <tt>seq a b</tt> is bottom if <tt>a</tt> is bottom, and
--   otherwise equal to <tt>b</tt>. In other words, it evaluates the first
--   argument <tt>a</tt> to weak head normal form (WHNF). <tt>seq</tt> is
--   usually introduced to improve performance by avoiding unneeded
--   laziness.
--   
--   A note on evaluation order: the expression <tt>seq a b</tt> does
--   <i>not</i> guarantee that <tt>a</tt> will be evaluated before
--   <tt>b</tt>. The only guarantee given by <tt>seq</tt> is that the both
--   <tt>a</tt> and <tt>b</tt> will be evaluated before <tt>seq</tt>
--   returns a value. In particular, this means that <tt>b</tt> may be
--   evaluated before <tt>a</tt>. If you need to guarantee a specific order
--   of evaluation, you must use the function <tt>pseq</tt> from the
--   "parallel" package.
seq :: () => a -> b -> b

-- | <a>filter</a>, applied to a predicate and a list, returns the list of
--   those elements that satisfy the predicate; i.e.,
--   
--   <pre>
--   filter p xs = [ x | x &lt;- xs, p x]
--   </pre>
filter :: () => a -> Bool -> [a] -> [a]

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
--   If one input list is short, excess elements of the longer list are
--   discarded.
--   
--   <a>zip</a> is right-lazy:
--   
--   <pre>
--   zip [] _|_ = []
--   </pre>
zip :: () => [a] -> [b] -> [(a, b)]

-- | The <a>print</a> function outputs a value of any printable type to the
--   standard output device. Printable types are those that are instances
--   of class <a>Show</a>; <a>print</a> converts values to strings for
--   output using the <a>show</a> operation and adds a newline.
--   
--   For example, a program to print the first 20 integers and their powers
--   of 2 could be written as:
--   
--   <pre>
--   main = print ([(n, 2^n) | n &lt;- [0..19]])
--   </pre>
print :: Show a => a -> IO ()

-- | Extract the first component of a pair.
fst :: () => (a, b) -> a

-- | Extract the second component of a pair.
snd :: () => (a, b) -> b

-- | <a>otherwise</a> is defined as the value <a>True</a>. It helps to make
--   guards more readable. eg.
--   
--   <pre>
--   f x | x &lt; 0     = ...
--       | otherwise = ...
--   </pre>
otherwise :: Bool

-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>
--   to each element of <tt>xs</tt>, i.e.,
--   
--   <pre>
--   map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
--   map f [x1, x2, ...] == [f x1, f x2, ...]
--   </pre>
map :: () => a -> b -> [a] -> [b]

-- | Application operator. This operator is redundant, since ordinary
--   application <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.
--   However, <a>$</a> has low, right-associative binding precedence, so it
--   sometimes allows parentheses to be omitted; for example:
--   
--   <pre>
--   f $ g $ h x  =  f (g (h x))
--   </pre>
--   
--   It is also useful in higher-order situations, such as <tt><a>map</a>
--   (<a>$</a> 0) xs</tt>, or <tt><a>zipWith</a> (<a>$</a>) fs xs</tt>.
($) :: () => a -> b -> a -> b
infixr 0 $

-- | general coercion from integral types
fromIntegral :: (Integral a, Num b) => a -> b

-- | general coercion to fractional types
realToFrac :: (Real a, Fractional b) => a -> b

-- | Conditional failure of <a>Alternative</a> computations. Defined by
--   
--   <pre>
--   guard True  = <a>pure</a> ()
--   guard False = <a>empty</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   Common uses of <a>guard</a> include conditionally signaling an error
--   in an error monad and conditionally rejecting the current choice in an
--   <a>Alternative</a>-based parser.
--   
--   As an example of signaling an error in the error monad <a>Maybe</a>,
--   consider a safe division function <tt>safeDiv x y</tt> that returns
--   <a>Nothing</a> when the denominator <tt>y</tt> is zero and
--   <tt><a>Just</a> (x `div` y)</tt> otherwise. For example:
--   
--   <pre>
--   &gt;&gt;&gt; safeDiv 4 0
--   Nothing
--   &gt;&gt;&gt; safeDiv 4 2
--   Just 2
--   </pre>
--   
--   A definition of <tt>safeDiv</tt> using guards, but not <a>guard</a>:
--   
--   <pre>
--   safeDiv :: Int -&gt; Int -&gt; Maybe Int
--   safeDiv x y | y /= 0    = Just (x `div` y)
--               | otherwise = Nothing
--   </pre>
--   
--   A definition of <tt>safeDiv</tt> using <a>guard</a> and <a>Monad</a>
--   <tt>do</tt>-notation:
--   
--   <pre>
--   safeDiv :: Int -&gt; Int -&gt; Maybe Int
--   safeDiv x y = do
--     guard (y /= 0)
--     return (x `div` y)
--   </pre>
guard :: Alternative f => Bool -> f ()

-- | The <a>join</a> function is the conventional monad join operator. It
--   is used to remove one level of monadic structure, projecting its bound
--   argument into the outer level.
join :: Monad m => m m a -> m a

-- | The <a>Bounded</a> class is used to name the upper and lower limits of
--   a type. <a>Ord</a> is not a superclass of <a>Bounded</a> since types
--   that are not totally ordered may also have upper and lower bounds.
--   
--   The <a>Bounded</a> class may be derived for any enumeration type;
--   <a>minBound</a> is the first constructor listed in the <tt>data</tt>
--   declaration and <a>maxBound</a> is the last. <a>Bounded</a> may also
--   be derived for single-constructor datatypes whose constituent types
--   are in <a>Bounded</a>.
class Bounded a
minBound :: Bounded a => a
maxBound :: Bounded a => a

-- | Class <a>Enum</a> defines operations on sequentially ordered types.
--   
--   The <tt>enumFrom</tt>... methods are used in Haskell's translation of
--   arithmetic sequences.
--   
--   Instances of <a>Enum</a> may be derived for any enumeration type
--   (types whose constructors have no fields). The nullary constructors
--   are assumed to be numbered left-to-right by <a>fromEnum</a> from
--   <tt>0</tt> through <tt>n-1</tt>. See Chapter 10 of the <i>Haskell
--   Report</i> for more details.
--   
--   For any type that is an instance of class <a>Bounded</a> as well as
--   <a>Enum</a>, the following should hold:
--   
--   <ul>
--   <li>The calls <tt><a>succ</a> <a>maxBound</a></tt> and <tt><a>pred</a>
--   <a>minBound</a></tt> should result in a runtime error.</li>
--   <li><a>fromEnum</a> and <a>toEnum</a> should give a runtime error if
--   the result value is not representable in the result type. For example,
--   <tt><a>toEnum</a> 7 :: <a>Bool</a></tt> is an error.</li>
--   <li><a>enumFrom</a> and <a>enumFromThen</a> should be defined with an
--   implicit bound, thus:</li>
--   </ul>
--   
--   <pre>
--   enumFrom     x   = enumFromTo     x maxBound
--   enumFromThen x y = enumFromThenTo x y bound
--     where
--       bound | fromEnum y &gt;= fromEnum x = maxBound
--             | otherwise                = minBound
--   </pre>
class Enum a

-- | the successor of a value. For numeric types, <a>succ</a> adds 1.
succ :: Enum a => a -> a

-- | the predecessor of a value. For numeric types, <a>pred</a> subtracts
--   1.
pred :: Enum a => a -> a

-- | Convert from an <a>Int</a>.
toEnum :: Enum a => Int -> a

-- | Convert to an <a>Int</a>. It is implementation-dependent what
--   <a>fromEnum</a> returns when applied to a value that is too large to
--   fit in an <a>Int</a>.
fromEnum :: Enum a => a -> Int

-- | Used in Haskell's translation of <tt>[n..]</tt>.
enumFrom :: Enum a => a -> [a]

-- | Used in Haskell's translation of <tt>[n,n'..]</tt>.
enumFromThen :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of <tt>[n..m]</tt>.
enumFromTo :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of <tt>[n,n'..m]</tt>.
enumFromThenTo :: Enum a => a -> a -> a -> [a]

-- | The <a>Eq</a> class defines equality (<a>==</a>) and inequality
--   (<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>
--   are instances of <a>Eq</a>, and <a>Eq</a> may be derived for any
--   datatype whose constituents are also instances of <a>Eq</a>.
--   
--   Minimal complete definition: either <a>==</a> or <a>/=</a>.
class Eq a
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool

-- | Trigonometric and hyperbolic functions and related functions.
class Fractional a => Floating a
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a

-- | Fractional numbers, supporting real division.
class Num a => Fractional a

-- | fractional division
(/) :: Fractional a => a -> a -> a

-- | reciprocal fraction
recip :: Fractional a => a -> a

-- | Conversion from a <a>Rational</a> (that is <tt><a>Ratio</a>
--   <a>Integer</a></tt>). A floating literal stands for an application of
--   <a>fromRational</a> to a value of type <a>Rational</a>, so such
--   literals have type <tt>(<a>Fractional</a> a) =&gt; a</tt>.
fromRational :: Fractional a => Rational -> a

-- | Integral numbers, supporting integer division.
class (Real a, Enum a) => Integral a

-- | integer division truncated toward zero
quot :: Integral a => a -> a -> a

-- | integer remainder, satisfying
--   
--   <pre>
--   (x `quot` y)*y + (x `rem` y) == x
--   </pre>
rem :: Integral a => a -> a -> a

-- | integer division truncated toward negative infinity
div :: Integral a => a -> a -> a

-- | integer modulus, satisfying
--   
--   <pre>
--   (x `div` y)*y + (x `mod` y) == x
--   </pre>
mod :: Integral a => a -> a -> a

-- | simultaneous <a>quot</a> and <a>rem</a>
quotRem :: Integral a => a -> a -> (a, a)

-- | simultaneous <a>div</a> and <a>mod</a>
divMod :: Integral a => a -> a -> (a, a)

-- | conversion to <a>Integer</a>
toInteger :: Integral a => a -> Integer

-- | The <a>Monad</a> class defines the basic operations over a
--   <i>monad</i>, a concept from a branch of mathematics known as
--   <i>category theory</i>. From the perspective of a Haskell programmer,
--   however, it is best to think of a monad as an <i>abstract datatype</i>
--   of actions. Haskell's <tt>do</tt> expressions provide a convenient
--   syntax for writing monadic expressions.
--   
--   Instances of <a>Monad</a> should satisfy the following laws:
--   
--   <ul>
--   <li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
--   <li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
--   <li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
--   <a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
--   </ul>
--   
--   Furthermore, the <a>Monad</a> and <a>Applicative</a> operations should
--   relate as follows:
--   
--   <ul>
--   <li><pre><a>pure</a> = <a>return</a></pre></li>
--   <li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
--   </ul>
--   
--   The above laws imply:
--   
--   <ul>
--   <li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
--   f</pre></li>
--   <li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
--   </ul>
--   
--   and that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
--   functor laws.
--   
--   The instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
--   defined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad (m :: * -> *)

-- | Sequentially compose two actions, passing any value produced by the
--   first as an argument to the second.
(>>=) :: Monad m => m a -> a -> m b -> m b

-- | Sequentially compose two actions, discarding any value produced by the
--   first, like sequencing operators (such as the semicolon) in imperative
--   languages.
(>>) :: Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | Fail with a message. This operation is not part of the mathematical
--   definition of a monad, but is invoked on pattern-match failure in a
--   <tt>do</tt> expression.
--   
--   As part of the MonadFail proposal (MFP), this function is moved to its
--   own class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
--   details). The definition here will be removed in a future release.
fail :: Monad m => String -> m a

-- | The <a>Functor</a> class is used for types that can be mapped over.
--   Instances of <a>Functor</a> should satisfy the following laws:
--   
--   <pre>
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   </pre>
--   
--   The instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
--   satisfy these laws.
class Functor (f :: * -> *)
fmap :: Functor f => a -> b -> f a -> f b

-- | Replace all locations in the input with the same value. The default
--   definition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | Basic numeric class.
class Num a
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a

-- | Unary negation.
negate :: Num a => a -> a

-- | Absolute value.
abs :: Num a => a -> a

-- | Sign of a number. The functions <a>abs</a> and <a>signum</a> should
--   satisfy the law:
--   
--   <pre>
--   abs x * signum x == x
--   </pre>
--   
--   For real numbers, the <a>signum</a> is either <tt>-1</tt> (negative),
--   <tt>0</tt> (zero) or <tt>1</tt> (positive).
signum :: Num a => a -> a

-- | Conversion from an <a>Integer</a>. An integer literal represents the
--   application of the function <a>fromInteger</a> to the appropriate
--   value of type <a>Integer</a>, so such literals have type
--   <tt>(<a>Num</a> a) =&gt; a</tt>.
fromInteger :: Num a => Integer -> a

-- | The <a>Ord</a> class is used for totally ordered datatypes.
--   
--   Instances of <a>Ord</a> can be derived for any user-defined datatype
--   whose constituent types are in <a>Ord</a>. The declared order of the
--   constructors in the data declaration determines the ordering in
--   derived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a
--   single comparison to determine the precise ordering of two objects.
--   
--   Minimal complete definition: either <a>compare</a> or <a>&lt;=</a>.
--   Using <a>compare</a> can be more efficient for complex types.
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a

-- | Parsing of <a>String</a>s, producing values.
--   
--   Derived instances of <a>Read</a> make the following assumptions, which
--   derived instances of <a>Show</a> obey:
--   
--   <ul>
--   <li>If the constructor is defined to be an infix operator, then the
--   derived <a>Read</a> instance will parse only infix applications of the
--   constructor (not the prefix form).</li>
--   <li>Associativity is not used to reduce the occurrence of parentheses,
--   although precedence may be.</li>
--   <li>If the constructor is defined using record syntax, the derived
--   <a>Read</a> will parse only the record-syntax form, and furthermore,
--   the fields must be given in the same order as the original
--   declaration.</li>
--   <li>The derived <a>Read</a> instance allows arbitrary Haskell
--   whitespace between tokens of the input string. Extra parentheses are
--   also allowed.</li>
--   </ul>
--   
--   For example, given the declarations
--   
--   <pre>
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   </pre>
--   
--   the derived instance of <a>Read</a> in Haskell 2010 is equivalent to
--   
--   <pre>
--   instance (Read a) =&gt; Read (Tree a) where
--   
--           readsPrec d r =  readParen (d &gt; app_prec)
--                            (\r -&gt; [(Leaf m,t) |
--                                    ("Leaf",s) &lt;- lex r,
--                                    (m,t) &lt;- readsPrec (app_prec+1) s]) r
--   
--                         ++ readParen (d &gt; up_prec)
--                            (\r -&gt; [(u:^:v,w) |
--                                    (u,s) &lt;- readsPrec (up_prec+1) r,
--                                    (":^:",t) &lt;- lex s,
--                                    (v,w) &lt;- readsPrec (up_prec+1) t]) r
--   
--             where app_prec = 10
--                   up_prec = 5
--   </pre>
--   
--   Note that right-associativity of <tt>:^:</tt> is unused.
--   
--   The derived instance in GHC is equivalent to
--   
--   <pre>
--   instance (Read a) =&gt; Read (Tree a) where
--   
--           readPrec = parens $ (prec app_prec $ do
--                                    Ident "Leaf" &lt;- lexP
--                                    m &lt;- step readPrec
--                                    return (Leaf m))
--   
--                        +++ (prec up_prec $ do
--                                    u &lt;- step readPrec
--                                    Symbol ":^:" &lt;- lexP
--                                    v &lt;- step readPrec
--                                    return (u :^: v))
--   
--             where app_prec = 10
--                   up_prec = 5
--   
--           readListPrec = readListPrecDefault
--   </pre>
--   
--   Why do both <a>readsPrec</a> and <a>readPrec</a> exist, and why does
--   GHC opt to implement <a>readPrec</a> in derived <a>Read</a> instances
--   instead of <a>readsPrec</a>? The reason is that <a>readsPrec</a> is
--   based on the <a>ReadS</a> type, and although <a>ReadS</a> is mentioned
--   in the Haskell 2010 Report, it is not a very efficient parser data
--   structure.
--   
--   <a>readPrec</a>, on the other hand, is based on a much more efficient
--   <a>ReadPrec</a> datatype (a.k.a "new-style parsers"), but its
--   definition relies on the use of the <tt>RankNTypes</tt> language
--   extension. Therefore, <a>readPrec</a> (and its cousin,
--   <a>readListPrec</a>) are marked as GHC-only. Nevertheless, it is
--   recommended to use <a>readPrec</a> instead of <a>readsPrec</a>
--   whenever possible for the efficiency improvements it brings.
--   
--   As mentioned above, derived <a>Read</a> instances in GHC will
--   implement <a>readPrec</a> instead of <a>readsPrec</a>. The default
--   implementations of <a>readsPrec</a> (and its cousin, <a>readList</a>)
--   will simply use <a>readPrec</a> under the hood. If you are writing a
--   <a>Read</a> instance by hand, it is recommended to write it like so:
--   
--   <pre>
--   instance <a>Read</a> T where
--     <a>readPrec</a>     = ...
--     <a>readListPrec</a> = <a>readListPrecDefault</a>
--   </pre>
class Read a

-- | attempts to parse a value from the front of the string, returning a
--   list of (parsed value, remaining string) pairs. If there is no
--   successful parse, the returned list is empty.
--   
--   Derived instances of <a>Read</a> and <a>Show</a> satisfy the
--   following:
--   
--   <ul>
--   <li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
--   (<a>showsPrec</a> d x ""))</tt>.</li>
--   </ul>
--   
--   That is, <a>readsPrec</a> parses the string produced by
--   <a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
--   with.
readsPrec :: Read a => Int -> ReadS a

-- | The method <a>readList</a> is provided to allow the programmer to give
--   a specialised way of parsing lists of values. For example, this is
--   used by the predefined <a>Read</a> instance of the <a>Char</a> type,
--   where values of type <a>String</a> should be are expected to use
--   double quotes, rather than square brackets.
readList :: Read a => ReadS [a]
class (Num a, Ord a) => Real a

-- | the rational equivalent of its real argument with full precision
toRational :: Real a => a -> Rational

-- | Efficient, machine-independent access to the components of a
--   floating-point number.
class (RealFrac a, Floating a) => RealFloat a

-- | a constant function, returning the radix of the representation (often
--   <tt>2</tt>)
floatRadix :: RealFloat a => a -> Integer

-- | a constant function, returning the number of digits of
--   <a>floatRadix</a> in the significand
floatDigits :: RealFloat a => a -> Int

-- | a constant function, returning the lowest and highest values the
--   exponent may assume
floatRange :: RealFloat a => a -> (Int, Int)

-- | The function <a>decodeFloat</a> applied to a real floating-point
--   number returns the significand expressed as an <a>Integer</a> and an
--   appropriately scaled exponent (an <a>Int</a>). If
--   <tt><a>decodeFloat</a> x</tt> yields <tt>(m,n)</tt>, then <tt>x</tt>
--   is equal in value to <tt>m*b^^n</tt>, where <tt>b</tt> is the
--   floating-point radix, and furthermore, either <tt>m</tt> and
--   <tt>n</tt> are both zero or else <tt>b^(d-1) &lt;= <a>abs</a> m &lt;
--   b^d</tt>, where <tt>d</tt> is the value of <tt><a>floatDigits</a>
--   x</tt>. In particular, <tt><a>decodeFloat</a> 0 = (0,0)</tt>. If the
--   type contains a negative zero, also <tt><a>decodeFloat</a> (-0.0) =
--   (0,0)</tt>. <i>The result of</i> <tt><a>decodeFloat</a> x</tt> <i>is
--   unspecified if either of</i> <tt><a>isNaN</a> x</tt> <i>or</i>
--   <tt><a>isInfinite</a> x</tt> <i>is</i> <a>True</a>.
decodeFloat :: RealFloat a => a -> (Integer, Int)

-- | <a>encodeFloat</a> performs the inverse of <a>decodeFloat</a> in the
--   sense that for finite <tt>x</tt> with the exception of <tt>-0.0</tt>,
--   <tt><tt>uncurry</tt> <a>encodeFloat</a> (<a>decodeFloat</a> x) =
--   x</tt>. <tt><a>encodeFloat</a> m n</tt> is one of the two closest
--   representable floating-point numbers to <tt>m*b^^n</tt> (or
--   <tt>±Infinity</tt> if overflow occurs); usually the closer, but if
--   <tt>m</tt> contains too many bits, the result may be rounded in the
--   wrong direction.
encodeFloat :: RealFloat a => Integer -> Int -> a

-- | <a>exponent</a> corresponds to the second component of
--   <a>decodeFloat</a>. <tt><a>exponent</a> 0 = 0</tt> and for finite
--   nonzero <tt>x</tt>, <tt><a>exponent</a> x = snd (<a>decodeFloat</a> x)
--   + <a>floatDigits</a> x</tt>. If <tt>x</tt> is a finite floating-point
--   number, it is equal in value to <tt><a>significand</a> x * b ^^
--   <a>exponent</a> x</tt>, where <tt>b</tt> is the floating-point radix.
--   The behaviour is unspecified on infinite or <tt>NaN</tt> values.
exponent :: RealFloat a => a -> Int

-- | The first component of <a>decodeFloat</a>, scaled to lie in the open
--   interval (<tt>-1</tt>,<tt>1</tt>), either <tt>0.0</tt> or of absolute
--   value <tt>&gt;= 1/b</tt>, where <tt>b</tt> is the floating-point
--   radix. The behaviour is unspecified on infinite or <tt>NaN</tt>
--   values.
significand :: RealFloat a => a -> a

-- | multiplies a floating-point number by an integer power of the radix
scaleFloat :: RealFloat a => Int -> a -> a

-- | <a>True</a> if the argument is an IEEE "not-a-number" (NaN) value
isNaN :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE infinity or negative infinity
isInfinite :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is too small to be represented in
--   normalized format
isDenormalized :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE negative zero
isNegativeZero :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE floating point number
isIEEE :: RealFloat a => a -> Bool

-- | a version of arctangent taking two real floating-point arguments. For
--   real floating <tt>x</tt> and <tt>y</tt>, <tt><a>atan2</a> y x</tt>
--   computes the angle (from the positive x-axis) of the vector from the
--   origin to the point <tt>(x,y)</tt>. <tt><a>atan2</a> y x</tt> returns
--   a value in the range [<tt>-pi</tt>, <tt>pi</tt>]. It follows the
--   Common Lisp semantics for the origin when signed zeroes are supported.
--   <tt><a>atan2</a> y 1</tt>, with <tt>y</tt> in a type that is
--   <a>RealFloat</a>, should return the same value as <tt><a>atan</a>
--   y</tt>. A default definition of <a>atan2</a> is provided, but
--   implementors can provide a more accurate implementation.
atan2 :: RealFloat a => a -> a -> a

-- | Extracting components of fractions.
class (Real a, Fractional a) => RealFrac a

-- | The function <a>properFraction</a> takes a real fractional number
--   <tt>x</tt> and returns a pair <tt>(n,f)</tt> such that <tt>x =
--   n+f</tt>, and:
--   
--   <ul>
--   <li><tt>n</tt> is an integral number with the same sign as <tt>x</tt>;
--   and</li>
--   <li><tt>f</tt> is a fraction with the same type and sign as
--   <tt>x</tt>, and with absolute value less than <tt>1</tt>.</li>
--   </ul>
--   
--   The default definitions of the <a>ceiling</a>, <a>floor</a>,
--   <a>truncate</a> and <a>round</a> functions are in terms of
--   <a>properFraction</a>.
properFraction :: (RealFrac a, Integral b) => a -> (b, a)

-- | <tt><a>truncate</a> x</tt> returns the integer nearest <tt>x</tt>
--   between zero and <tt>x</tt>
truncate :: (RealFrac a, Integral b) => a -> b

-- | <tt><a>round</a> x</tt> returns the nearest integer to <tt>x</tt>; the
--   even integer if <tt>x</tt> is equidistant between two integers
round :: (RealFrac a, Integral b) => a -> b

-- | <tt><a>ceiling</a> x</tt> returns the least integer not less than
--   <tt>x</tt>
ceiling :: (RealFrac a, Integral b) => a -> b

-- | <tt><a>floor</a> x</tt> returns the greatest integer not greater than
--   <tt>x</tt>
floor :: (RealFrac a, Integral b) => a -> b

-- | Conversion of values to readable <a>String</a>s.
--   
--   Derived instances of <a>Show</a> have the following properties, which
--   are compatible with derived instances of <a>Read</a>:
--   
--   <ul>
--   <li>The result of <a>show</a> is a syntactically correct Haskell
--   expression containing only constants, given the fixity declarations in
--   force at the point where the type is declared. It contains only the
--   constructor names defined in the data type, parentheses, and spaces.
--   When labelled constructor fields are used, braces, commas, field
--   names, and equal signs are also used.</li>
--   <li>If the constructor is defined to be an infix operator, then
--   <a>showsPrec</a> will produce infix applications of the
--   constructor.</li>
--   <li>the representation will be enclosed in parentheses if the
--   precedence of the top-level constructor in <tt>x</tt> is less than
--   <tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is
--   <tt>0</tt> then the result is never surrounded in parentheses; if
--   <tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,
--   unless it is an atomic expression.</li>
--   <li>If the constructor is defined using record syntax, then
--   <a>show</a> will produce the record-syntax form, with the fields given
--   in the same order as the original declaration.</li>
--   </ul>
--   
--   For example, given the declarations
--   
--   <pre>
--   infixr 5 :^:
--   data Tree a =  Leaf a  |  Tree a :^: Tree a
--   </pre>
--   
--   the derived instance of <a>Show</a> is equivalent to
--   
--   <pre>
--   instance (Show a) =&gt; Show (Tree a) where
--   
--          showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
--               showString "Leaf " . showsPrec (app_prec+1) m
--            where app_prec = 10
--   
--          showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
--               showsPrec (up_prec+1) u .
--               showString " :^: "      .
--               showsPrec (up_prec+1) v
--            where up_prec = 5
--   </pre>
--   
--   Note that right-associativity of <tt>:^:</tt> is ignored. For example,
--   
--   <ul>
--   <li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the
--   string <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>
--   </ul>
class Show a

-- | Convert a value to a readable <a>String</a>.
--   
--   <a>showsPrec</a> should satisfy the law
--   
--   <pre>
--   showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
--   </pre>
--   
--   Derived instances of <a>Read</a> and <a>Show</a> satisfy the
--   following:
--   
--   <ul>
--   <li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
--   (<a>showsPrec</a> d x ""))</tt>.</li>
--   </ul>
--   
--   That is, <a>readsPrec</a> parses the string produced by
--   <a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
--   with.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of <a>showsPrec</a>, using precedence context
--   zero, and returning an ordinary <a>String</a>.
show :: Show a => a -> String

-- | The method <a>showList</a> is provided to allow the programmer to give
--   a specialised way of showing lists of values. For example, this is
--   used by the predefined <a>Show</a> instance of the <a>Char</a> type,
--   where values of type <a>String</a> should be shown in double quotes,
--   rather than between square brackets.
showList :: Show a => [a] -> ShowS

-- | A functor with application, providing operations to
--   
--   <ul>
--   <li>embed pure expressions (<a>pure</a>), and</li>
--   <li>sequence computations and combine their results (<a>&lt;*&gt;</a>
--   and <a>liftA2</a>).</li>
--   </ul>
--   
--   A minimal complete definition must include implementations of
--   <a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
--   defines both, then they must behave the same as their default
--   definitions:
--   
--   <pre>
--   (<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>liftA2</a> f x y = f <tt>&lt;$&gt;</tt> x <a>&lt;*&gt;</a> y
--   </pre>
--   
--   Further, any definition must satisfy the following:
--   
--   <ul>
--   <li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
--   v = v</pre></li>
--   <li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
--   <a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
--   <a>&lt;*&gt;</a> w)</pre></li>
--   <li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
--   <a>pure</a> x = <a>pure</a> (f x)</pre></li>
--   <li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
--   <a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
--   </ul>
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   <ul>
--   <li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
--   <a>&lt;*&gt;</a> v</pre></li>
--   <li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
--   </ul>
--   
--   As a consequence of these laws, the <a>Functor</a> instance for
--   <tt>f</tt> will satisfy
--   
--   <ul>
--   <li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
--   </ul>
--   
--   It may be useful to note that supposing
--   
--   <pre>
--   forall x y. p (q x y) = f x . g y
--   </pre>
--   
--   it follows from the above that
--   
--   <pre>
--   <a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
--   </pre>
--   
--   If <tt>f</tt> is also a <a>Monad</a>, it should satisfy
--   
--   <ul>
--   <li><pre><a>pure</a> = <a>return</a></pre></li>
--   <li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
--   <li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
--   </ul>
--   
--   (which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
--   applicative functor laws).
class Functor f => Applicative (f :: * -> *)

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
--   
--   A few functors support an implementation of <a>&lt;*&gt;</a> that is
--   more efficient than the default one.
(<*>) :: Applicative f => f a -> b -> f a -> f b

-- | Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a

-- | Data structures that can be folded.
--   
--   For example, given a data type
--   
--   <pre>
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   </pre>
--   
--   a suitable instance would be
--   
--   <pre>
--   instance Foldable Tree where
--      foldMap f Empty = mempty
--      foldMap f (Leaf x) = f x
--      foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
--   </pre>
--   
--   This is suitable even for abstract types, as the monoid is assumed to
--   satisfy the monoid laws. Alternatively, one could define
--   <tt>foldr</tt>:
--   
--   <pre>
--   instance Foldable Tree where
--      foldr f z Empty = z
--      foldr f z (Leaf x) = f x z
--      foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
--   </pre>
--   
--   <tt>Foldable</tt> instances are expected to satisfy the following
--   laws:
--   
--   <pre>
--   foldr f z t = appEndo (foldMap (Endo . f) t ) z
--   </pre>
--   
--   <pre>
--   foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
--   </pre>
--   
--   <pre>
--   fold = foldMap id
--   </pre>
--   
--   <pre>
--   length = getSum . foldMap (Sum . const  1)
--   </pre>
--   
--   <tt>sum</tt>, <tt>product</tt>, <tt>maximum</tt>, and <tt>minimum</tt>
--   should all be essentially equivalent to <tt>foldMap</tt> forms, such
--   as
--   
--   <pre>
--   sum = getSum . foldMap Sum
--   </pre>
--   
--   but may be less defined.
--   
--   If the type is also a <a>Functor</a> instance, it should satisfy
--   
--   <pre>
--   foldMap f = fold . fmap f
--   </pre>
--   
--   which implies that
--   
--   <pre>
--   foldMap f . fmap g = foldMap (f . g)
--   </pre>
class Foldable (t :: * -> *)

-- | Combine the elements of a structure using a monoid.
fold :: (Foldable t, Monoid m) => t m -> m

-- | Map each element of the structure to a monoid, and combine the
--   results.
foldMap :: (Foldable t, Monoid m) => a -> m -> t a -> m

-- | Right-associative fold of a structure.
--   
--   In the case of lists, <a>foldr</a>, when applied to a binary operator,
--   a starting value (typically the right-identity of the operator), and a
--   list, reduces the list using the binary operator, from right to left:
--   
--   <pre>
--   foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
--   </pre>
--   
--   Note that, since the head of the resulting expression is produced by
--   an application of the operator to the first element of the list,
--   <a>foldr</a> can produce a terminating expression from an infinite
--   list.
--   
--   For a general <a>Foldable</a> structure this should be semantically
--   identical to,
--   
--   <pre>
--   foldr f z = <a>foldr</a> f z . <a>toList</a>
--   </pre>
foldr :: Foldable t => a -> b -> b -> b -> t a -> b

-- | Right-associative fold of a structure, but with strict application of
--   the operator.
foldr' :: Foldable t => a -> b -> b -> b -> t a -> b

-- | Left-associative fold of a structure.
--   
--   In the case of lists, <a>foldl</a>, when applied to a binary operator,
--   a starting value (typically the left-identity of the operator), and a
--   list, reduces the list using the binary operator, from left to right:
--   
--   <pre>
--   foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
--   </pre>
--   
--   Note that to produce the outermost application of the operator the
--   entire input list must be traversed. This means that <a>foldl'</a>
--   will diverge if given an infinite list.
--   
--   Also note that if you want an efficient left-fold, you probably want
--   to use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
--   that latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
--   x1</tt> in the above example) before applying them to the operator
--   (e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
--   <tt>O(n)</tt> elements long, which then must be evaluated from the
--   outside-in.
--   
--   For a general <a>Foldable</a> structure this should be semantically
--   identical to,
--   
--   <pre>
--   foldl f z = <a>foldl</a> f z . <a>toList</a>
--   </pre>
foldl :: Foldable t => b -> a -> b -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
--   the operator.
--   
--   This ensures that each step of the fold is forced to weak head normal
--   form before being applied, avoiding the collection of thunks that
--   would otherwise occur. This is often what you want to strictly reduce
--   a finite list to a single, monolithic result (e.g. <a>length</a>).
--   
--   For a general <a>Foldable</a> structure this should be semantically
--   identical to,
--   
--   <pre>
--   foldl f z = <a>foldl'</a> f z . <a>toList</a>
--   </pre>
foldl' :: Foldable t => b -> a -> b -> b -> t a -> b

-- | A variant of <a>foldr</a> that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   <pre>
--   <a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
--   </pre>
foldr1 :: Foldable t => a -> a -> a -> t a -> a

-- | A variant of <a>foldl</a> that has no base case, and thus may only be
--   applied to non-empty structures.
--   
--   <pre>
--   <a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
--   </pre>
foldl1 :: Foldable t => a -> a -> a -> t a -> a

-- | List of elements of a structure, from left to right.
toList :: Foldable t => t a -> [a]

-- | Test whether the structure is empty. The default implementation is
--   optimized for structures that are similar to cons-lists, because there
--   is no general way to do better.
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an <a>Int</a>. The
--   default implementation is optimized for structures that are similar to
--   cons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

-- | Does the element occur in the structure?
elem :: (Foldable t, Eq a) => a -> t a -> Bool

-- | The largest element of a non-empty structure.
maximum :: (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
minimum :: (Foldable t, Ord a) => t a -> a

-- | The <a>sum</a> function computes the sum of the numbers of a
--   structure.
sum :: (Foldable t, Num a) => t a -> a

-- | The <a>product</a> function computes the product of the numbers of a
--   structure.
product :: (Foldable t, Num a) => t a -> a

-- | Functors representing data structures that can be traversed from left
--   to right.
--   
--   A definition of <a>traverse</a> must satisfy the following laws:
--   
--   <ul>
--   <li><i><i>naturality</i></i> <tt>t . <a>traverse</a> f =
--   <a>traverse</a> (t . f)</tt> for every applicative transformation
--   <tt>t</tt></li>
--   <li><i><i>identity</i></i> <tt><a>traverse</a> Identity =
--   Identity</tt></li>
--   <li><i><i>composition</i></i> <tt><a>traverse</a> (Compose .
--   <a>fmap</a> g . f) = Compose . <a>fmap</a> (<a>traverse</a> g) .
--   <a>traverse</a> f</tt></li>
--   </ul>
--   
--   A definition of <a>sequenceA</a> must satisfy the following laws:
--   
--   <ul>
--   <li><i><i>naturality</i></i> <tt>t . <a>sequenceA</a> =
--   <a>sequenceA</a> . <a>fmap</a> t</tt> for every applicative
--   transformation <tt>t</tt></li>
--   <li><i><i>identity</i></i> <tt><a>sequenceA</a> . <a>fmap</a> Identity
--   = Identity</tt></li>
--   <li><i><i>composition</i></i> <tt><a>sequenceA</a> . <a>fmap</a>
--   Compose = Compose . <a>fmap</a> <a>sequenceA</a> .
--   <a>sequenceA</a></tt></li>
--   </ul>
--   
--   where an <i>applicative transformation</i> is a function
--   
--   <pre>
--   t :: (Applicative f, Applicative g) =&gt; f a -&gt; g a
--   </pre>
--   
--   preserving the <a>Applicative</a> operations, i.e.
--   
--   <ul>
--   <li><pre>t (<a>pure</a> x) = <a>pure</a> x</pre></li>
--   <li><pre>t (x <a>&lt;*&gt;</a> y) = t x <a>&lt;*&gt;</a> t
--   y</pre></li>
--   </ul>
--   
--   and the identity functor <tt>Identity</tt> and composition of functors
--   <tt>Compose</tt> are defined as
--   
--   <pre>
--   newtype Identity a = Identity a
--   
--   instance Functor Identity where
--     fmap f (Identity x) = Identity (f x)
--   
--   instance Applicative Identity where
--     pure x = Identity x
--     Identity f &lt;*&gt; Identity x = Identity (f x)
--   
--   newtype Compose f g a = Compose (f (g a))
--   
--   instance (Functor f, Functor g) =&gt; Functor (Compose f g) where
--     fmap f (Compose x) = Compose (fmap (fmap f) x)
--   
--   instance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
--     pure x = Compose (pure (pure x))
--     Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
--   </pre>
--   
--   (The naturality law is implied by parametricity.)
--   
--   Instances are similar to <a>Functor</a>, e.g. given a data type
--   
--   <pre>
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   </pre>
--   
--   a suitable instance would be
--   
--   <pre>
--   instance Traversable Tree where
--      traverse f Empty = pure Empty
--      traverse f (Leaf x) = Leaf &lt;$&gt; f x
--      traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
--   </pre>
--   
--   This is suitable even for abstract types, as the laws for
--   <a>&lt;*&gt;</a> imply a form of associativity.
--   
--   The superclass instances should satisfy the following:
--   
--   <ul>
--   <li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
--   to traversal with the identity applicative functor
--   (<a>fmapDefault</a>).</li>
--   <li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
--   equivalent to traversal with a constant applicative functor
--   (<a>foldMapDefault</a>).</li>
--   </ul>
class (Functor t, Foldable t) => Traversable (t :: * -> *)

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and collect the results. For a version that
--   ignores the results see <a>traverse_</a>.
traverse :: (Traversable t, Applicative f) => a -> f b -> t a -> f t b

-- | Evaluate each action in the structure from left to right, and and
--   collect the results. For a version that ignores the results see
--   <a>sequenceA_</a>.
sequenceA :: (Traversable t, Applicative f) => t f a -> f t a

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and collect the results. For a version
--   that ignores the results see <a>mapM_</a>.
mapM :: (Traversable t, Monad m) => a -> m b -> t a -> m t b

-- | Evaluate each monadic action in the structure from left to right, and
--   collect the results. For a version that ignores the results see
--   <a>sequence_</a>.
sequence :: (Traversable t, Monad m) => t m a -> m t a

-- | The class of semigroups (types with an associative binary operation).
--   
--   Instances should satisfy the associativity law:
--   
--   <ul>
--   <li><pre>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
--   y) <a>&lt;&gt;</a> z</pre></li>
--   </ul>
class Semigroup a

-- | An associative operation.
(<>) :: Semigroup a => a -> a -> a

-- | The class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following laws:
--   
--   <ul>
--   <li><pre>x <a>&lt;&gt;</a> <a>mempty</a> = x</pre></li>
--   <li><pre><a>mempty</a> <a>&lt;&gt;</a> x = x</pre></li>
--   <li><tt>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
--   y) <a>&lt;&gt;</a> z</tt> (<a>Semigroup</a> law)</li>
--   <li><pre><a>mconcat</a> = <a>foldr</a> '(&lt;&gt;)'
--   <a>mempty</a></pre></li>
--   </ul>
--   
--   The method names refer to the monoid of lists under concatenation, but
--   there are many other instances.
--   
--   Some types can be viewed as a monoid in more than one way, e.g. both
--   addition and multiplication on numbers. In such cases we often define
--   <tt>newtype</tt>s and make those instances of <a>Monoid</a>, e.g.
--   <tt>Sum</tt> and <tt>Product</tt>.
--   
--   <b>NOTE</b>: <a>Semigroup</a> is a superclass of <a>Monoid</a> since
--   <i>base-4.11.0.0</i>.
class Semigroup a => Monoid a

-- | Identity of <a>mappend</a>
mempty :: Monoid a => a

-- | An associative operation
--   
--   <b>NOTE</b>: This method is redundant and has the default
--   implementation <tt><a>mappend</a> = '(&lt;&gt;)'</tt> since
--   <i>base-4.11.0.0</i>.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
--   
--   For most types, the default definition for <a>mconcat</a> will be
--   used, but the function is included in the class definition so that an
--   optimized version can be provided for specific types.
mconcat :: Monoid a => [a] -> a
data Bool
False :: Bool
True :: Bool

-- | The character type <a>Char</a> is an enumeration whose values
--   represent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
--   characters, see <a>http://www.unicode.org/</a> for details). This set
--   extends the ISO 8859-1 (Latin-1) character set (the first 256
--   characters), which is itself an extension of the ASCII character set
--   (the first 128 characters). A character literal in Haskell has type
--   <a>Char</a>.
--   
--   To convert a <a>Char</a> to or from the corresponding <a>Int</a> value
--   defined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
--   <a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
--   <tt>chr</tt>).
data Char

-- | Double-precision floating point numbers. It is desirable that this
--   type be at least equal in range and precision to the IEEE
--   double-precision type.
data Double

-- | Single-precision floating point numbers. It is desirable that this
--   type be at least equal in range and precision to the IEEE
--   single-precision type.
data Float

-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..
--   2^29-1]</tt>. The exact range for a given implementation can be
--   determined by using <a>minBound</a> and <a>maxBound</a> from the
--   <a>Bounded</a> class.
data Int

-- | Invariant: <a>Jn#</a> and <a>Jp#</a> are used iff value doesn't fit in
--   <a>S#</a>
--   
--   Useful properties resulting from the invariants:
--   
--   <ul>
--   <li><pre>abs (<a>S#</a> _) &lt;= abs (<a>Jp#</a> _)</pre></li>
--   <li><pre>abs (<a>S#</a> _) &lt; abs (<a>Jn#</a> _)</pre></li>
--   </ul>
data Integer

-- | The <a>Maybe</a> type encapsulates an optional value. A value of type
--   <tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
--   (represented as <tt><a>Just</a> a</tt>), or it is empty (represented
--   as <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
--   errors or exceptional cases without resorting to drastic measures such
--   as <a>error</a>.
--   
--   The <a>Maybe</a> type is also a monad. It is a simple kind of error
--   monad, where all errors are represented by <a>Nothing</a>. A richer
--   error monad can be built using the <a>Either</a> type.
data Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

-- | Arbitrary-precision rational numbers, represented as a ratio of two
--   <a>Integer</a> values. A rational number may be constructed using the
--   <a>%</a> operator.
type Rational = Ratio Integer

-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when
--   performed, does some I/O before returning a value of type <tt>a</tt>.
--   
--   There is really only one way to "perform" an I/O action: bind it to
--   <tt>Main.main</tt> in your program. When your program is run, the I/O
--   will be performed. It isn't possible to perform I/O from an arbitrary
--   function, unless that function is itself in the <a>IO</a> monad and
--   called at some point, directly or indirectly, from <tt>Main.main</tt>.
--   
--   <a>IO</a> is a monad, so <a>IO</a> actions can be combined using
--   either the do-notation or the <tt>&gt;&gt;</tt> and <tt>&gt;&gt;=</tt>
--   operations from the <tt>Monad</tt> class.
data IO a

-- | A <a>Word</a> is an unsigned integral type, with the same size as
--   <a>Int</a>.
data Word

-- | The <a>Either</a> type represents values with two possibilities: a
--   value of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>
--   a</tt> or <tt><a>Right</a> b</tt>.
--   
--   The <a>Either</a> type is sometimes used to represent a value which is
--   either correct or an error; by convention, the <a>Left</a> constructor
--   is used to hold an error value and the <a>Right</a> constructor is
--   used to hold a correct value (mnemonic: "right" also means "correct").
--   
--   <h4><b>Examples</b></h4>
--   
--   The type <tt><a>Either</a> <a>String</a> <a>Int</a></tt> is the type
--   of values which can be either a <a>String</a> or an <a>Int</a>. The
--   <a>Left</a> constructor can be used only on <a>String</a>s, and the
--   <a>Right</a> constructor can be used only on <a>Int</a>s:
--   
--   <pre>
--   &gt;&gt;&gt; let s = Left "foo" :: Either String Int
--   
--   &gt;&gt;&gt; s
--   Left "foo"
--   
--   &gt;&gt;&gt; let n = Right 3 :: Either String Int
--   
--   &gt;&gt;&gt; n
--   Right 3
--   
--   &gt;&gt;&gt; :type s
--   s :: Either String Int
--   
--   &gt;&gt;&gt; :type n
--   n :: Either String Int
--   </pre>
--   
--   The <a>fmap</a> from our <a>Functor</a> instance will ignore
--   <a>Left</a> values, but will apply the supplied function to values
--   contained in a <a>Right</a>:
--   
--   <pre>
--   &gt;&gt;&gt; let s = Left "foo" :: Either String Int
--   
--   &gt;&gt;&gt; let n = Right 3 :: Either String Int
--   
--   &gt;&gt;&gt; fmap (*2) s
--   Left "foo"
--   
--   &gt;&gt;&gt; fmap (*2) n
--   Right 6
--   </pre>
--   
--   The <a>Monad</a> instance for <a>Either</a> allows us to chain
--   together multiple actions which may fail, and fail overall if any of
--   the individual steps failed. First we'll write a function that can
--   either parse an <a>Int</a> from a <a>Char</a>, or fail.
--   
--   <pre>
--   &gt;&gt;&gt; import Data.Char ( digitToInt, isDigit )
--   
--   &gt;&gt;&gt; :{
--       let parseEither :: Char -&gt; Either String Int
--           parseEither c
--             | isDigit c = Right (digitToInt c)
--             | otherwise = Left "parse error"
--   
--   &gt;&gt;&gt; :}
--   </pre>
--   
--   The following should work, since both <tt>'1'</tt> and <tt>'2'</tt>
--   can be parsed as <a>Int</a>s.
--   
--   <pre>
--   &gt;&gt;&gt; :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x &lt;- parseEither '1'
--             y &lt;- parseEither '2'
--             return (x + y)
--   
--   &gt;&gt;&gt; :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; parseMultiple
--   Right 3
--   </pre>
--   
--   But the following should fail overall, since the first operation where
--   we attempt to parse <tt>'m'</tt> as an <a>Int</a> will fail:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--       let parseMultiple :: Either String Int
--           parseMultiple = do
--             x &lt;- parseEither 'm'
--             y &lt;- parseEither '2'
--             return (x + y)
--   
--   &gt;&gt;&gt; :}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; parseMultiple
--   Left "parse error"
--   </pre>
data Either a b
Left :: a -> Either a b
Right :: b -> Either a b

-- | A <a>String</a> is a list of characters. String constants in Haskell
--   are values of type <a>String</a>.
type String = [Char]

-- | The <tt>shows</tt> functions return a function that prepends the
--   output <a>String</a> to an existing <a>String</a>. This allows
--   constant-time concatenation of results using function composition.
type ShowS = String -> String

-- | A space-efficient representation of a <a>Word8</a> vector, supporting
--   many efficient operations.
--   
--   A <a>ByteString</a> contains 8-bit bytes, or by using the operations
--   from <a>Data.ByteString.Char8</a> it can be interpreted as containing
--   8-bit characters.
data ByteString

-- | An infix synonym for <a>fmap</a>.
--   
--   The name of this operator is an allusion to <tt>$</tt>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
--   function application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
--   <tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
--   an <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
--   <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <tt>even</tt> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: Functor f => a -> b -> f a -> f b
infixl 4 <$>

-- | A space efficient, packed, unboxed Unicode text type.
data Text

-- | This is the simplest representation of UTC. It consists of the day
--   number, and a time offset from midnight. Note that if a day has a leap
--   second added to it, it will have 86401 seconds.
data UTCTime
UTCTime :: Day -> DiffTime -> UTCTime

-- | the day
[utctDay] :: UTCTime -> Day

-- | the time from midnight, 0 &lt;= t &lt; 86401s (because of
--   leap-seconds)
[utctDayTime] :: UTCTime -> DiffTime

-- | A type that can be converted to JSON.
--   
--   Instances in general <i>must</i> specify <a>toJSON</a> and
--   <i>should</i> (but don't need to) specify <a>toEncoding</a>.
--   
--   An example type and instance:
--   
--   <pre>
--   -- Allow ourselves to write <a>Text</a> literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance <a>ToJSON</a> Coord where
--     <a>toJSON</a> (Coord x y) = <a>object</a> ["x" <a>.=</a> x, "y" <a>.=</a> y]
--   
--     <a>toEncoding</a> (Coord x y) = <tt>pairs</tt> ("x" <a>.=</a> x <a>&lt;&gt;</a> "y" <a>.=</a> y)
--   </pre>
--   
--   Instead of manually writing your <a>ToJSON</a> instance, there are two
--   options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>toJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic</a></tt>
--   clause to your datatype and declare a <a>ToJSON</a> instance. If you
--   require nothing other than <a>defaultOptions</a>, it is sufficient to
--   write (and this is the only alternative where the default
--   <a>toJSON</a> implementation is sufficient):
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving <a>Generic</a>
--   
--   instance <a>ToJSON</a> Coord where
--       <a>toEncoding</a> = <a>genericToEncoding</a> <a>defaultOptions</a>
--   </pre>
--   
--   If on the other hand you wish to customize the generic decoding, you
--   have to implement both methods:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>ToJSON</a> Coord where
--       <a>toJSON</a>     = <a>genericToJSON</a> customOptions
--       <a>toEncoding</a> = <a>genericToEncoding</a> customOptions
--   </pre>
--   
--   Previous versions of this library only had the <a>toJSON</a> method.
--   Adding <a>toEncoding</a> had to reasons:
--   
--   <ol>
--   <li>toEncoding is more efficient for the common case that the output
--   of <a>toJSON</a> is directly serialized to a <tt>ByteString</tt>.
--   Further, expressing either method in terms of the other would be
--   non-optimal.</li>
--   <li>The choice of defaults allows a smooth transition for existing
--   users: Existing instances that do not define <a>toEncoding</a> still
--   compile and have the correct semantics. This is ensured by making the
--   default implementation of <a>toEncoding</a> use <a>toJSON</a>. This
--   produces correct results, but since it performs an intermediate
--   conversion to a <a>Value</a>, it will be less efficient than directly
--   emitting an <a>Encoding</a>. (this also means that specifying nothing
--   more than <tt>instance ToJSON Coord</tt> would be sufficient as a
--   generically decoding instance, but there probably exists no good
--   reason to not specify <a>toEncoding</a> in new instances.)</li>
--   </ol>
class ToJSON a

-- | Convert a Haskell value to a JSON-friendly intermediate type.
toJSON :: ToJSON a => a -> Value

-- | Encode a Haskell value as JSON.
--   
--   The default implementation of this method creates an intermediate
--   <a>Value</a> using <a>toJSON</a>. This provides source-level
--   compatibility for people upgrading from older versions of this
--   library, but obviously offers no performance advantage.
--   
--   To benefit from direct encoding, you <i>must</i> provide an
--   implementation for this method. The easiest way to do so is by having
--   your types implement <a>Generic</a> using the <tt>DeriveGeneric</tt>
--   extension, and then have GHC generate a method body as follows.
--   
--   <pre>
--   instance <a>ToJSON</a> Coord where
--       <a>toEncoding</a> = <a>genericToEncoding</a> <a>defaultOptions</a>
--   </pre>
toEncoding :: ToJSON a => a -> Encoding
toJSONList :: ToJSON a => [a] -> Value
toEncodingList :: ToJSON a => [a] -> Encoding
(.=) :: (KeyValue kv, ToJSON v) => Text -> v -> kv
infixr 8 .=

-- | Retrieve the value associated with the given key of an <a>Object</a>.
--   The result is <tt>empty</tt> if the key is not present or the value
--   cannot be converted to the desired type.
--   
--   This accessor is appropriate if the key and value <i>must</i> be
--   present in an object for it to be valid. If the key and value are
--   optional, use <a>.:?</a> instead.
(.:) :: FromJSON a => Object -> Text -> Parser a

-- | A type that can be converted from JSON, with the possibility of
--   failure.
--   
--   In many cases, you can get the compiler to generate parsing code for
--   you (see below). To begin, let's cover writing an instance by hand.
--   
--   There are various reasons a conversion could fail. For example, an
--   <a>Object</a> could be missing a required key, an <a>Array</a> could
--   be of the wrong size, or a value could be of an incompatible type.
--   
--   The basic ways to signal a failed conversion are as follows:
--   
--   <ul>
--   <li><tt>empty</tt> and <tt>mzero</tt> work, but are terse and
--   uninformative;</li>
--   <li><a>fail</a> yields a custom error message;</li>
--   <li><a>typeMismatch</a> produces an informative message for cases when
--   the value encountered is not of the expected type.</li>
--   </ul>
--   
--   An example type and instance using <a>typeMismatch</a>:
--   
--   <pre>
--   -- Allow ourselves to write <a>Text</a> literals.
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   data Coord = Coord { x :: Double, y :: Double }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> (<a>Object</a> v) = Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   
--       -- We do not expect a non-<a>Object</a> value here.
--       -- We could use <tt>mzero</tt> to fail, but <a>typeMismatch</a>
--       -- gives a much more informative error message.
--       <a>parseJSON</a> invalid    = <a>typeMismatch</a> "Coord" invalid
--   </pre>
--   
--   For this common case of only being concerned with a single type of
--   JSON value, the functions <a>withObject</a>, <a>withNumber</a>, etc.
--   are provided. Their use is to be preferred when possible, since they
--   are more terse. Using <a>withObject</a>, we can rewrite the above
--   instance (assuming the same language extension and data type) as:
--   
--   <pre>
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>withObject</a> "Coord" $ \v -&gt; Coord
--           <a>&lt;$&gt;</a> v <a>.:</a> "x"
--           <a>&lt;*&gt;</a> v <a>.:</a> "y"
--   </pre>
--   
--   Instead of manually writing your <a>FromJSON</a> instance, there are
--   two options to do it automatically:
--   
--   <ul>
--   <li><a>Data.Aeson.TH</a> provides Template Haskell functions which
--   will derive an instance at compile time. The generated instance is
--   optimized for your type so it will probably be more efficient than the
--   following option.</li>
--   <li>The compiler can provide a default generic implementation for
--   <a>parseJSON</a>.</li>
--   </ul>
--   
--   To use the second, simply add a <tt>deriving <a>Generic</a></tt>
--   clause to your datatype and declare a <a>FromJSON</a> instance for
--   your datatype without giving a definition for <a>parseJSON</a>.
--   
--   For example, the previous example can be simplified to just:
--   
--   <pre>
--   {-# LANGUAGE DeriveGeneric #-}
--   
--   import <a>GHC.Generics</a>
--   
--   data Coord = Coord { x :: Double, y :: Double } deriving <a>Generic</a>
--   
--   instance <a>FromJSON</a> Coord
--   </pre>
--   
--   The default implementation will be equivalent to <tt>parseJSON =
--   <a>genericParseJSON</a> <a>defaultOptions</a></tt>; If you need
--   different options, you can customize the generic decoding by defining:
--   
--   <pre>
--   customOptions = <a>defaultOptions</a>
--                   { <a>fieldLabelModifier</a> = <a>map</a> <a>toUpper</a>
--                   }
--   
--   instance <a>FromJSON</a> Coord where
--       <a>parseJSON</a> = <a>genericParseJSON</a> customOptions
--   </pre>
class FromJSON a
parseJSON :: FromJSON a => Value -> Parser a
parseJSONList :: FromJSON a => Value -> Parser [a]

-- | Create a <a>Value</a> from a list of name/value <a>Pair</a>s. If
--   duplicate keys arise, earlier keys and their associated values win.
object :: [Pair] -> Value

-- | A JSON value represented as a Haskell value.
data Value
Object :: !Object -> Value
Array :: !Array -> Value
String :: !Text -> Value
Number :: !Scientific -> Value
Bool :: !Bool -> Value
Null :: Value

-- | The <a>read</a> function reads input from a string, which must be
--   completely consumed by the input process. <a>read</a> fails with an
--   <a>error</a> if the parse is unsuccessful, and it is therefore
--   discouraged from being used in real applications. Use <a>readMaybe</a>
--   or <a>readEither</a> for safe alternatives.
--   
--   <pre>
--   &gt;&gt;&gt; read "123" :: Int
--   123
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; read "hello" :: Int
--   *** Exception: Prelude.read: no parse
--   </pre>
read :: Read a => String -> a

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: * -> *)

-- | The identity of <a>mplus</a>. It should also satisfy the equations
--   
--   <pre>
--   mzero &gt;&gt;= f  =  mzero
--   v &gt;&gt; mzero   =  mzero
--   </pre>
--   
--   The default definition is
--   
--   <pre>
--   mzero = <a>empty</a>
--   </pre>
mzero :: MonadPlus m => m a

-- | An associative operation. The default definition is
--   
--   <pre>
--   mplus = (<a>&lt;|&gt;</a>)
--   </pre>
mplus :: MonadPlus m => m a -> m a -> m a

-- | Uninhabited data type
data Void

-- | A bifunctor is a type constructor that takes two type arguments and is
--   a functor in <i>both</i> arguments. That is, unlike with
--   <a>Functor</a>, a type constructor such as <a>Either</a> does not need
--   to be partially applied for a <a>Bifunctor</a> instance, and the
--   methods in this class permit mapping functions over the <a>Left</a>
--   value or the <a>Right</a> value, or both at the same time.
--   
--   Formally, the class <a>Bifunctor</a> represents a bifunctor from
--   <tt>Hask</tt> -&gt; <tt>Hask</tt>.
--   
--   Intuitively it is a bifunctor where both the first and second
--   arguments are covariant.
--   
--   You can define a <a>Bifunctor</a> by either defining <a>bimap</a> or
--   by defining both <a>first</a> and <a>second</a>.
--   
--   If you supply <a>bimap</a>, you should ensure that:
--   
--   <pre>
--   <a>bimap</a> <a>id</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply <a>first</a> and <a>second</a>, ensure:
--   
--   <pre>
--   <a>first</a> <a>id</a> ≡ <a>id</a>
--   <a>second</a> <a>id</a> ≡ <a>id</a>
--   </pre>
--   
--   If you supply both, you should also ensure:
--   
--   <pre>
--   <a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
--   </pre>
--   
--   These ensure by parametricity:
--   
--   <pre>
--   <a>bimap</a>  (f <a>.</a> g) (h <a>.</a> i) ≡ <a>bimap</a> f h <a>.</a> <a>bimap</a> g i
--   <a>first</a>  (f <a>.</a> g) ≡ <a>first</a>  f <a>.</a> <a>first</a>  g
--   <a>second</a> (f <a>.</a> g) ≡ <a>second</a> f <a>.</a> <a>second</a> g
--   </pre>
class Bifunctor (p :: * -> * -> *)

-- | Map over both arguments at the same time.
--   
--   <pre>
--   <a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) ('j', 3)
--   ('J',4)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) (Left 'j')
--   Left 'J'
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; bimap toUpper (+1) (Right 3)
--   Right 4
--   </pre>
bimap :: Bifunctor p => a -> b -> c -> d -> p a c -> p b d

-- | Map covariantly over the first argument.
--   
--   <pre>
--   <a>first</a> f ≡ <a>bimap</a> f <a>id</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; first toUpper ('j', 3)
--   ('J',3)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; first toUpper (Left 'j')
--   Left 'J'
--   </pre>
first :: Bifunctor p => a -> b -> p a c -> p b c

-- | Map covariantly over the second argument.
--   
--   <pre>
--   <a>second</a> ≡ <a>bimap</a> <a>id</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; second (+1) ('j', 3)
--   ('j',4)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; second (+1) (Right 3)
--   Right 4
--   </pre>
second :: Bifunctor p => b -> c -> p a b -> p a c

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
--   built by applying a sequence of monad transformers to the <a>IO</a>
--   monad will be an instance of this class.
--   
--   Instances should satisfy the following laws, which state that
--   <a>liftIO</a> is a transformer of monads:
--   
--   <ul>
--   <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
--   (<a>liftIO</a> . f)</pre></li>
--   </ul>
class Monad m => MonadIO (m :: * -> *)

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a

-- | Direct <a>MonadPlus</a> equivalent of <tt>filter</tt>
--   <tt><tt>filter</tt></tt> = <tt>(mfilter:: (a -&gt; Bool) -&gt; [a]
--   -&gt; [a]</tt> applicable to any <a>MonadPlus</a>, for example
--   <tt>mfilter odd (Just 1) == Just 1</tt> <tt>mfilter odd (Just 2) ==
--   Nothing</tt>
mfilter :: MonadPlus m => a -> Bool -> m a -> m a

-- | Strict version of <a>&lt;$&gt;</a>.
(<$!>) :: Monad m => a -> b -> m a -> m b
infixl 4 <$!>

-- | The reverse of <a>when</a>.
unless :: Applicative f => Bool -> f () -> f ()

-- | Like <a>replicateM</a>, but discards the result.
replicateM_ :: Applicative m => Int -> m a -> m ()

-- | <tt><a>replicateM</a> n act</tt> performs the action <tt>n</tt> times,
--   gathering the results.
replicateM :: Applicative m => Int -> m a -> m [a]

-- | Like <a>foldM</a>, but discards the result.
foldM_ :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m ()

-- | The <a>foldM</a> function is analogous to <tt>foldl</tt>, except that
--   its result is encapsulated in a monad. Note that <a>foldM</a> works
--   from left-to-right over the list arguments. This could be an issue
--   where <tt>(<a>&gt;&gt;</a>)</tt> and the `folded function' are not
--   commutative.
--   
--   <pre>
--   foldM f a1 [x1, x2, ..., xm]
--   
--   ==
--   
--   do
--     a2 &lt;- f a1 x1
--     a3 &lt;- f a2 x2
--     ...
--     f am xm
--   </pre>
--   
--   If right-to-left evaluation is required, the input list should be
--   reversed.
--   
--   Note: <a>foldM</a> is the same as <a>foldlM</a>
foldM :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m b

-- | <a>zipWithM_</a> is the extension of <a>zipWithM</a> which ignores the
--   final result.
zipWithM_ :: Applicative m => a -> b -> m c -> [a] -> [b] -> m ()

-- | The <a>zipWithM</a> function generalizes <a>zipWith</a> to arbitrary
--   applicative functors.
zipWithM :: Applicative m => a -> b -> m c -> [a] -> [b] -> m [c]

-- | The <a>mapAndUnzipM</a> function maps its first argument over a list,
--   returning the result as a pair of lists. This function is mainly used
--   with complicated data structures or a state-transforming monad.
mapAndUnzipM :: Applicative m => a -> m (b, c) -> [a] -> m ([b], [c])

-- | <tt><a>forever</a> act</tt> repeats the action infinitely.
forever :: Applicative f => f a -> f b

-- | Right-to-left Kleisli composition of monads.
--   <tt>(<a>&gt;=&gt;</a>)</tt>, with the arguments flipped.
--   
--   Note how this operator resembles function composition
--   <tt>(<a>.</a>)</tt>:
--   
--   <pre>
--   (.)   ::            (b -&gt;   c) -&gt; (a -&gt;   b) -&gt; a -&gt;   c
--   (&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
--   </pre>
(<=<) :: Monad m => b -> m c -> a -> m b -> a -> m c
infixr 1 <=<

-- | Left-to-right Kleisli composition of monads.
(>=>) :: Monad m => a -> m b -> b -> m c -> a -> m c
infixr 1 >=>

-- | This generalizes the list-based <tt>filter</tt> function.
filterM :: Applicative m => a -> m Bool -> [a] -> m [a]

-- | This function may be used as a value for <a>foldMap</a> in a
--   <a>Foldable</a> instance.
--   
--   <pre>
--   <a>foldMapDefault</a> f ≡ <a>getConst</a> . <a>traverse</a> (<a>Const</a> . f)
--   </pre>
foldMapDefault :: (Traversable t, Monoid m) => a -> m -> t a -> m

-- | This function may be used as a value for <a>fmap</a> in a
--   <a>Functor</a> instance, provided that <a>traverse</a> is defined.
--   (Using <a>fmapDefault</a> with a <a>Traversable</a> instance defined
--   only by <a>sequenceA</a> will result in infinite recursion.)
--   
--   <pre>
--   <a>fmapDefault</a> f ≡ <a>runIdentity</a> . <a>traverse</a> (<a>Identity</a> . f)
--   </pre>
fmapDefault :: Traversable t => a -> b -> t a -> t b

-- | The <a>mapAccumR</a> function behaves like a combination of
--   <a>fmap</a> and <tt>foldr</tt>; it applies a function to each element
--   of a structure, passing an accumulating parameter from right to left,
--   and returning a final value of this accumulator together with the new
--   structure.
mapAccumR :: Traversable t => a -> b -> (a, c) -> a -> t b -> (a, t c)

-- | The <a>mapAccumL</a> function behaves like a combination of
--   <a>fmap</a> and <tt>foldl</tt>; it applies a function to each element
--   of a structure, passing an accumulating parameter from left to right,
--   and returning a final value of this accumulator together with the new
--   structure.
mapAccumL :: Traversable t => a -> b -> (a, c) -> a -> t b -> (a, t c)

-- | <a>forM</a> is <a>mapM</a> with its arguments flipped. For a version
--   that ignores the results see <a>forM_</a>.
forM :: (Traversable t, Monad m) => t a -> a -> m b -> m t b

-- | <a>for</a> is <a>traverse</a> with its arguments flipped. For a
--   version that ignores the results see <a>for_</a>.
for :: (Traversable t, Applicative f) => t a -> a -> f b -> f t b

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
--   signals parse failure to the <a>IO</a> monad instead of terminating
--   the program.
readIO :: Read a => String -> IO a

-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.
readLn :: Read a => IO a

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
--   the string <tt>str</tt>, to the file <tt>file</tt>.
--   
--   Note that <a>writeFile</a> and <a>appendFile</a> write a literal
--   string to a file. To write a value of any printable type, as with
--   <a>print</a>, use the <a>show</a> function to convert the value to a
--   string first.
--   
--   <pre>
--   main = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
--   </pre>
appendFile :: FilePath -> String -> IO ()

-- | The <a>interact</a> function takes a function of type
--   <tt>String-&gt;String</tt> as its argument. The entire input from the
--   standard input device is passed to this function as its argument, and
--   the resulting string is output on the standard output device.
interact :: String -> String -> IO ()

-- | The <a>getContents</a> operation returns all user input as a single
--   string, which is read lazily as it is needed (same as
--   <a>hGetContents</a> <a>stdin</a>).
getContents :: IO String

-- | Read a line from the standard input device (same as <a>hGetLine</a>
--   <a>stdin</a>).
getLine :: IO String

-- | Read a character from the standard input device (same as
--   <a>hGetChar</a> <a>stdin</a>).
getChar :: IO Char

-- | The same as <a>putStr</a>, but adds a newline character.
putStrLn :: String -> IO ()

-- | Write a string to the standard output device (same as <a>hPutStr</a>
--   <a>stdout</a>).
putStr :: String -> IO ()

-- | Write a character to the standard output device (same as
--   <a>hPutChar</a> <a>stdout</a>).
putChar :: Char -> IO ()

-- | Raise an <a>IOError</a> in the <a>IO</a> monad.
ioError :: () => IOError -> IO a

-- | File and directory names are values of type <a>String</a>, whose
--   precise meaning is operating system dependent. Files can be opened,
--   yielding a handle which can then be used to operate on the contents of
--   that file.
type FilePath = String

-- | Construct an <a>IOError</a> value with a string describing the error.
--   The <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>
--   class raises a <a>userError</a>, thus:
--   
--   <pre>
--   instance Monad IO where
--     ...
--     fail s = ioError (userError s)
--   </pre>
userError :: String -> IOError

-- | The Haskell 2010 type for exceptions in the <a>IO</a> monad. Any I/O
--   operation may raise an <a>IOError</a> instead of returning a result.
--   For a more general type of exception, including also those that arise
--   in pure code, see <a>Exception</a>.
--   
--   In Haskell 2010, this is an opaque type.
type IOError = IOException

-- | The <a>find</a> function takes a predicate and a structure and returns
--   the leftmost element of the structure matching the predicate, or
--   <a>Nothing</a> if there is no such element.
find :: Foldable t => a -> Bool -> t a -> Maybe a

-- | <a>notElem</a> is the negation of <a>elem</a>.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | The least element of a non-empty structure with respect to the given
--   comparison function.
minimumBy :: Foldable t => a -> a -> Ordering -> t a -> a

-- | The largest element of a non-empty structure with respect to the given
--   comparison function.
maximumBy :: Foldable t => a -> a -> Ordering -> t a -> a

-- | Determines whether all elements of the structure satisfy the
--   predicate.
all :: Foldable t => a -> Bool -> t a -> Bool

-- | Determines whether any element of the structure satisfies the
--   predicate.
any :: Foldable t => a -> Bool -> t a -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
--   result to be <a>False</a>, the container must be finite; <a>True</a>,
--   however, results from a <a>True</a> value finitely far from the left
--   end.
or :: Foldable t => t Bool -> Bool

-- | <a>and</a> returns the conjunction of a container of Bools. For the
--   result to be <a>True</a>, the container must be finite; <a>False</a>,
--   however, results from a <a>False</a> value finitely far from the left
--   end.
and :: Foldable t => t Bool -> Bool

-- | Map a function over all the elements of a container and concatenate
--   the resulting lists.
concatMap :: Foldable t => a -> [b] -> t a -> [b]

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | The sum of a collection of actions, generalizing <a>concat</a>. As of
--   base 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
--   <a>MonadPlus</a>.
msum :: (Foldable t, MonadPlus m) => t m a -> m a

-- | The sum of a collection of actions, generalizing <a>concat</a>.
--   
--   asum [Just <a>Hello</a>, Nothing, Just <a>World</a>] Just <a>Hello</a>
asum :: (Foldable t, Alternative f) => t f a -> f a

-- | Evaluate each monadic action in the structure from left to right, and
--   ignore the results. For a version that doesn't ignore the results see
--   <a>sequence</a>.
--   
--   As of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
--   specialized to <a>Monad</a>.
sequence_ :: (Foldable t, Monad m) => t m a -> m ()

-- | Evaluate each action in the structure from left to right, and ignore
--   the results. For a version that doesn't ignore the results see
--   <a>sequenceA</a>.
sequenceA_ :: (Foldable t, Applicative f) => t f a -> f ()

-- | <a>forM_</a> is <a>mapM_</a> with its arguments flipped. For a version
--   that doesn't ignore the results see <a>forM</a>.
--   
--   As of base 4.8.0.0, <a>forM_</a> is just <a>for_</a>, specialized to
--   <a>Monad</a>.
forM_ :: (Foldable t, Monad m) => t a -> a -> m b -> m ()

-- | Map each element of a structure to a monadic action, evaluate these
--   actions from left to right, and ignore the results. For a version that
--   doesn't ignore the results see <a>mapM</a>.
--   
--   As of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
--   to <a>Monad</a>.
mapM_ :: (Foldable t, Monad m) => a -> m b -> t a -> m ()

-- | <a>for_</a> is <a>traverse_</a> with its arguments flipped. For a
--   version that doesn't ignore the results see <a>for</a>.
--   
--   <pre>
--   &gt;&gt;&gt; for_ [1..4] print
--   1
--   2
--   3
--   4
--   </pre>
for_ :: (Foldable t, Applicative f) => t a -> a -> f b -> f ()

-- | Map each element of a structure to an action, evaluate these actions
--   from left to right, and ignore the results. For a version that doesn't
--   ignore the results see <a>traverse</a>.
traverse_ :: (Foldable t, Applicative f) => a -> f b -> t a -> f ()

-- | Monadic fold over the elements of a structure, associating to the
--   left, i.e. from left to right.
foldlM :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m b

-- | Monadic fold over the elements of a structure, associating to the
--   right, i.e. from right to left.
foldrM :: (Foldable t, Monad m) => a -> b -> m b -> b -> t a -> m b

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
--   with separating spaces.
--   
--   <pre>
--   &gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
--   "Lorem ipsum dolor"
--   </pre>
unwords :: [String] -> String

-- | <a>words</a> breaks a string up into a list of words, which were
--   delimited by white space.
--   
--   <pre>
--   &gt;&gt;&gt; words "Lorem ipsum\ndolor"
--   ["Lorem","ipsum","dolor"]
--   </pre>
words :: String -> [String]

-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins
--   lines, after appending a terminating newline to each.
--   
--   <pre>
--   &gt;&gt;&gt; unlines ["Hello", "World", "!"]
--   "Hello\nWorld\n!\n"
--   </pre>
unlines :: [String] -> String

-- | <a>lines</a> breaks a string up into a list of strings at newline
--   characters. The resulting strings do not contain newlines.
--   
--   Note that after splitting the string at newline characters, the last
--   part of the string is considered a line even if it doesn't end with a
--   newline. For example,
--   
--   <pre>
--   &gt;&gt;&gt; lines ""
--   []
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "\n"
--   [""]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "one"
--   ["one"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "one\n"
--   ["one"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "one\n\n"
--   ["one",""]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "one\ntwo"
--   ["one","two"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lines "one\ntwo\n"
--   ["one","two"]
--   </pre>
--   
--   Thus <tt><a>lines</a> s</tt> contains at least as many elements as
--   newlines in <tt>s</tt>.
lines :: String -> [String]

-- | The <a>unfoldr</a> function is a `dual' to <a>foldr</a>: while
--   <a>foldr</a> reduces a list to a summary value, <a>unfoldr</a> builds
--   a list from a seed value. The function takes the element and returns
--   <a>Nothing</a> if it is done producing the list or returns <a>Just</a>
--   <tt>(a,b)</tt>, in which case, <tt>a</tt> is a prepended to the list
--   and <tt>b</tt> is used as the next element in a recursive call. For
--   example,
--   
--   <pre>
--   iterate f == unfoldr (\x -&gt; Just (x, f x))
--   </pre>
--   
--   In some cases, <a>unfoldr</a> can undo a <a>foldr</a> operation:
--   
--   <pre>
--   unfoldr f' (foldr f z xs) == xs
--   </pre>
--   
--   if the following holds:
--   
--   <pre>
--   f' (f x y) = Just (x,y)
--   f' z       = Nothing
--   </pre>
--   
--   A simple use of unfoldr:
--   
--   <pre>
--   &gt;&gt;&gt; unfoldr (\b -&gt; if b == 0 then Nothing else Just (b, b-1)) 10
--   [10,9,8,7,6,5,4,3,2,1]
--   </pre>
unfoldr :: () => b -> Maybe (a, b) -> b -> [a]

-- | equivalent to <a>readsPrec</a> with a precedence of 0.
reads :: Read a => ReadS a

-- | Return the contents of a <a>Right</a>-value or a default value
--   otherwise.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; fromRight 1 (Right 3)
--   3
--   
--   &gt;&gt;&gt; fromRight 1 (Left "foo")
--   1
--   </pre>
fromRight :: () => b -> Either a b -> b

-- | Return the contents of a <a>Left</a>-value or a default value
--   otherwise.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; fromLeft 1 (Left 3)
--   3
--   
--   &gt;&gt;&gt; fromLeft 1 (Right "foo")
--   1
--   </pre>
fromLeft :: () => a -> Either a b -> a

-- | Return <a>True</a> if the given value is a <a>Right</a>-value,
--   <a>False</a> otherwise.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; isRight (Left "foo")
--   False
--   
--   &gt;&gt;&gt; isRight (Right 3)
--   True
--   </pre>
--   
--   Assuming a <a>Left</a> value signifies some sort of error, we can use
--   <a>isRight</a> to write a very simple reporting function that only
--   outputs "SUCCESS" when a computation has succeeded.
--   
--   This example shows how <a>isRight</a> might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   <pre>
--   &gt;&gt;&gt; import Control.Monad ( when )
--   
--   &gt;&gt;&gt; let report e = when (isRight e) $ putStrLn "SUCCESS"
--   
--   &gt;&gt;&gt; report (Left "parse error")
--   
--   &gt;&gt;&gt; report (Right 1)
--   SUCCESS
--   </pre>
isRight :: () => Either a b -> Bool

-- | Return <a>True</a> if the given value is a <a>Left</a>-value,
--   <a>False</a> otherwise.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; isLeft (Left "foo")
--   True
--   
--   &gt;&gt;&gt; isLeft (Right 3)
--   False
--   </pre>
--   
--   Assuming a <a>Left</a> value signifies some sort of error, we can use
--   <a>isLeft</a> to write a very simple error-reporting function that
--   does absolutely nothing in the case of success, and outputs "ERROR" if
--   any error occurred.
--   
--   This example shows how <a>isLeft</a> might be used to avoid pattern
--   matching when one does not care about the value contained in the
--   constructor:
--   
--   <pre>
--   &gt;&gt;&gt; import Control.Monad ( when )
--   
--   &gt;&gt;&gt; let report e = when (isLeft e) $ putStrLn "ERROR"
--   
--   &gt;&gt;&gt; report (Right 1)
--   
--   &gt;&gt;&gt; report (Left "parse error")
--   ERROR
--   </pre>
isLeft :: () => Either a b -> Bool

-- | Partitions a list of <a>Either</a> into two lists. All the <a>Left</a>
--   elements are extracted, in order, to the first component of the
--   output. Similarly the <a>Right</a> elements are extracted to the
--   second component of the output.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   &gt;&gt;&gt; partitionEithers list
--   (["foo","bar","baz"],[3,7])
--   </pre>
--   
--   The pair returned by <tt><a>partitionEithers</a> x</tt> should be the
--   same pair as <tt>(<a>lefts</a> x, <a>rights</a> x)</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   &gt;&gt;&gt; partitionEithers list == (lefts list, rights list)
--   True
--   </pre>
partitionEithers :: () => [Either a b] -> ([a], [b])

-- | Extracts from a list of <a>Either</a> all the <a>Right</a> elements.
--   All the <a>Right</a> elements are extracted in order.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   &gt;&gt;&gt; rights list
--   [3,7]
--   </pre>
rights :: () => [Either a b] -> [b]

-- | Extracts from a list of <a>Either</a> all the <a>Left</a> elements.
--   All the <a>Left</a> elements are extracted in order.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
--   
--   &gt;&gt;&gt; lefts list
--   ["foo","bar","baz"]
--   </pre>
lefts :: () => [Either a b] -> [a]

-- | Case analysis for the <a>Either</a> type. If the value is
--   <tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it
--   is <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.
--   
--   <h4><b>Examples</b></h4>
--   
--   We create two values of type <tt><a>Either</a> <a>String</a>
--   <a>Int</a></tt>, one using the <a>Left</a> constructor and another
--   using the <a>Right</a> constructor. Then we apply "either" the
--   <tt>length</tt> function (if we have a <a>String</a>) or the
--   "times-two" function (if we have an <a>Int</a>):
--   
--   <pre>
--   &gt;&gt;&gt; let s = Left "foo" :: Either String Int
--   
--   &gt;&gt;&gt; let n = Right 3 :: Either String Int
--   
--   &gt;&gt;&gt; either length (*2) s
--   3
--   
--   &gt;&gt;&gt; either length (*2) n
--   6
--   </pre>
either :: () => a -> c -> b -> c -> Either a b -> c

-- | The <a>lex</a> function reads a single lexeme from the input,
--   discarding initial white space, and returning the characters that
--   constitute the lexeme. If the input string contains only white space,
--   <a>lex</a> returns a single successful `lexeme' consisting of the
--   empty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
--   no legal lexeme at the beginning of the input string, <a>lex</a> fails
--   (i.e. returns <tt>[]</tt>).
--   
--   This lexer is not completely faithful to the Haskell lexical syntax in
--   the following respects:
--   
--   <ul>
--   <li>Qualified names are not handled properly</li>
--   <li>Octal and hexadecimal numerics are not recognized as a single
--   token</li>
--   <li>Comments are not treated properly</li>
--   </ul>
lex :: ReadS String

-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,
--   but surrounded with parentheses.
--   
--   <tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
--   parses, but optionally surrounded with parentheses.
readParen :: () => Bool -> ReadS a -> ReadS a

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
--   <a>String</a> and returns a list of possible parses as
--   <tt>(a,<a>String</a>)</tt> pairs.
--   
--   Note that this kind of backtracking parser is very inefficient;
--   reading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]

-- | <tt><a>void</a> value</tt> discards or ignores the result of
--   evaluation, such as the return value of an <a>IO</a> action.
--   
--   <h4><b>Examples</b></h4>
--   
--   Replace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
--   unit:
--   
--   <pre>
--   &gt;&gt;&gt; void Nothing
--   Nothing
--   
--   &gt;&gt;&gt; void (Just 3)
--   Just ()
--   </pre>
--   
--   Replace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
--   <tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
--   <tt>Int</tt> '()'</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; void (Left 8675309)
--   Left 8675309
--   
--   &gt;&gt;&gt; void (Right 8675309)
--   Right ()
--   </pre>
--   
--   Replace every element of a list with unit:
--   
--   <pre>
--   &gt;&gt;&gt; void [1,2,3]
--   [(),(),()]
--   </pre>
--   
--   Replace the second element of a pair with unit:
--   
--   <pre>
--   &gt;&gt;&gt; void (1,2)
--   (1,())
--   </pre>
--   
--   Discard the result of an <a>IO</a> action:
--   
--   <pre>
--   &gt;&gt;&gt; mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   &gt;&gt;&gt; void $ mapM print [1,2]
--   1
--   2
--   </pre>
void :: Functor f => f a -> f ()

-- | <tt><a>lcm</a> x y</tt> is the smallest positive integer that both
--   <tt>x</tt> and <tt>y</tt> divide.
lcm :: Integral a => a -> a -> a

-- | <tt><a>gcd</a> x y</tt> is the non-negative factor of both <tt>x</tt>
--   and <tt>y</tt> of which every common factor of <tt>x</tt> and
--   <tt>y</tt> is also a factor; for example <tt><a>gcd</a> 4 2 = 2</tt>,
--   <tt><a>gcd</a> (-4) 6 = 2</tt>, <tt><a>gcd</a> 0 4</tt> = <tt>4</tt>.
--   <tt><a>gcd</a> 0 0</tt> = <tt>0</tt>. (That is, the common divisor
--   that is "greatest" in the divisibility preordering.)
--   
--   Note: Since for signed fixed-width integer types, <tt><a>abs</a>
--   <a>minBound</a> &lt; 0</tt>, the result may be negative if one of the
--   arguments is <tt><a>minBound</a></tt> (and necessarily is if the other
--   is <tt>0</tt> or <tt><a>minBound</a></tt>) for such types.
gcd :: Integral a => a -> a -> a

-- | raise a number to an integral power
(^^) :: (Fractional a, Integral b) => a -> b -> a
infixr 8 ^^

-- | raise a number to a non-negative integral power
(^) :: (Num a, Integral b) => a -> b -> a
infixr 8 ^
odd :: Integral a => a -> Bool
even :: Integral a => a -> Bool

-- | utility function that surrounds the inner show function with
--   parentheses when the <a>Bool</a> parameter is <a>True</a>.
showParen :: Bool -> ShowS -> ShowS

-- | utility function converting a <a>String</a> to a show function that
--   simply prepends the string unchanged.
showString :: String -> ShowS

-- | utility function converting a <a>Char</a> to a show function that
--   simply prepends the character unchanged.
showChar :: Char -> ShowS

-- | equivalent to <a>showsPrec</a> with a precedence of 0.
shows :: Show a => a -> ShowS

-- | The <a>unzip3</a> function takes a list of triples and returns three
--   lists, analogous to <a>unzip</a>.
unzip3 :: () => [(a, b, c)] -> ([a], [b], [c])

-- | <a>unzip</a> transforms a list of pairs into a list of first
--   components and a list of second components.
unzip :: () => [(a, b)] -> ([a], [b])

-- | The <a>zipWith3</a> function takes a function which combines three
--   elements, as well as three lists and returns a list of their
--   point-wise combination, analogous to <a>zipWith</a>.
zipWith3 :: () => a -> b -> c -> d -> [a] -> [b] -> [c] -> [d]

-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function
--   given as the first argument, instead of a tupling function. For
--   example, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
--   produce the list of corresponding sums.
--   
--   <a>zipWith</a> is right-lazy:
--   
--   <pre>
--   zipWith f [] _|_ = []
--   </pre>
zipWith :: () => a -> b -> c -> [a] -> [b] -> [c]

-- | <a>zip3</a> takes three lists and returns a list of triples, analogous
--   to <a>zip</a>.
zip3 :: () => [a] -> [b] -> [c] -> [(a, b, c)]

-- | List index (subscript) operator, starting from 0. It is an instance of
--   the more general <a>genericIndex</a>, which takes an index of any
--   integral type.
(!!) :: () => [a] -> Int -> a
infixl 9 !!

-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association
--   list.
lookup :: Eq a => a -> [(a, b)] -> Maybe b

-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in
--   reverse order. <tt>xs</tt> must be finite.
reverse :: () => [a] -> [a]

-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list
--   <tt>xs</tt>, returns a tuple where first element is longest prefix
--   (possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
--   <tt>p</tt> and second element is the remainder of the list:
--   
--   <pre>
--   break (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
--   break (&lt; 9) [1,2,3] == ([],[1,2,3])
--   break (&gt; 9) [1,2,3] == ([1,2,3],[])
--   </pre>
--   
--   <a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
--   p)</tt>.
break :: () => a -> Bool -> [a] -> ([a], [a])

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
--   returns a tuple where first element is longest prefix (possibly empty)
--   of <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
--   is the remainder of the list:
--   
--   <pre>
--   span (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
--   span (&lt; 9) [1,2,3] == ([1,2,3],[])
--   span (&lt; 0) [1,2,3] == ([],[1,2,3])
--   </pre>
--   
--   <a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
--   <a>dropWhile</a> p xs)</tt>
span :: () => a -> Bool -> [a] -> ([a], [a])

-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is
--   <tt>xs</tt> prefix of length <tt>n</tt> and second element is the
--   remainder of the list:
--   
--   <pre>
--   splitAt 6 "Hello World!" == ("Hello ","World!")
--   splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
--   splitAt 1 [1,2,3] == ([1],[2,3])
--   splitAt 3 [1,2,3] == ([1,2,3],[])
--   splitAt 4 [1,2,3] == ([1,2,3],[])
--   splitAt 0 [1,2,3] == ([],[1,2,3])
--   splitAt (-1) [1,2,3] == ([],[1,2,3])
--   </pre>
--   
--   It is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
--   <tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
--   <a>splitAt</a> is an instance of the more general
--   <a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
--   type.
splitAt :: () => Int -> [a] -> ([a], [a])

-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the
--   first <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
--   xs</tt>:
--   
--   <pre>
--   drop 6 "Hello World!" == "World!"
--   drop 3 [1,2,3,4,5] == [4,5]
--   drop 3 [1,2] == []
--   drop 3 [] == []
--   drop (-1) [1,2] == [1,2]
--   drop 0 [1,2] == [1,2]
--   </pre>
--   
--   It is an instance of the more general <a>genericDrop</a>, in which
--   <tt>n</tt> may be of any integral type.
drop :: () => Int -> [a] -> [a]

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
--   prefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
--   <tt>n &gt; <a>length</a> xs</tt>:
--   
--   <pre>
--   take 5 "Hello World!" == "Hello"
--   take 3 [1,2,3,4,5] == [1,2,3]
--   take 3 [1,2] == [1,2]
--   take 3 [] == []
--   take (-1) [1,2] == []
--   take 0 [1,2] == []
--   </pre>
--   
--   It is an instance of the more general <a>genericTake</a>, in which
--   <tt>n</tt> may be of any integral type.
take :: () => Int -> [a] -> [a]

-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after
--   <a>takeWhile</a> <tt>p xs</tt>:
--   
--   <pre>
--   dropWhile (&lt; 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
--   dropWhile (&lt; 9) [1,2,3] == []
--   dropWhile (&lt; 0) [1,2,3] == [1,2,3]
--   </pre>
dropWhile :: () => a -> Bool -> [a] -> [a]

-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list
--   <tt>xs</tt>, returns the longest prefix (possibly empty) of
--   <tt>xs</tt> of elements that satisfy <tt>p</tt>:
--   
--   <pre>
--   takeWhile (&lt; 3) [1,2,3,4,1,2,3,4] == [1,2]
--   takeWhile (&lt; 9) [1,2,3] == [1,2,3]
--   takeWhile (&lt; 0) [1,2,3] == []
--   </pre>
takeWhile :: () => a -> Bool -> [a] -> [a]

-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,
--   the infinite repetition of the original list. It is the identity on
--   infinite lists.
cycle :: () => [a] -> [a]

-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with
--   <tt>x</tt> the value of every element. It is an instance of the more
--   general <a>genericReplicate</a>, in which <tt>n</tt> may be of any
--   integral type.
replicate :: () => Int -> a -> [a]

-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the
--   value of every element.
repeat :: () => a -> [a]

-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated
--   applications of <tt>f</tt> to <tt>x</tt>:
--   
--   <pre>
--   iterate f x == [x, f x, f (f x), ...]
--   </pre>
--   
--   Note that <a>iterate</a> is lazy, potentially leading to thunk
--   build-up if the consumer doesn't force each iterate. See 'iterate\''
--   for a strict variant of this function.
iterate :: () => a -> a -> a -> [a]

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
--   argument.
scanr1 :: () => a -> a -> a -> [a] -> [a]

-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that
--   
--   <pre>
--   head (scanr f z xs) == foldr f z xs.
--   </pre>
scanr :: () => a -> b -> b -> b -> [a] -> [b]

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
--   argument:
--   
--   <pre>
--   scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
--   </pre>
scanl1 :: () => a -> a -> a -> [a] -> [a]

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
--   successive reduced values from the left:
--   
--   <pre>
--   scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
--   </pre>
--   
--   Note that
--   
--   <pre>
--   last (scanl f z xs) == foldl f z xs.
--   </pre>
scanl :: () => b -> a -> b -> b -> [a] -> [b]

-- | The <a>mapMaybe</a> function is a version of <a>map</a> which can
--   throw out elements. In particular, the functional argument returns
--   something of type <tt><a>Maybe</a> b</tt>. If this is <a>Nothing</a>,
--   no element is added on to the result list. If it is <tt><a>Just</a>
--   b</tt>, then <tt>b</tt> is included in the result list.
--   
--   <h4><b>Examples</b></h4>
--   
--   Using <tt><a>mapMaybe</a> f x</tt> is a shortcut for
--   <tt><a>catMaybes</a> $ <a>map</a> f x</tt> in most cases:
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; let readMaybeInt = readMaybe :: String -&gt; Maybe Int
--   
--   &gt;&gt;&gt; mapMaybe readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   &gt;&gt;&gt; catMaybes $ map readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   </pre>
--   
--   If we map the <a>Just</a> constructor, the entire list should be
--   returned:
--   
--   <pre>
--   &gt;&gt;&gt; mapMaybe Just [1,2,3]
--   [1,2,3]
--   </pre>
mapMaybe :: () => a -> Maybe b -> [a] -> [b]

-- | The <a>catMaybes</a> function takes a list of <a>Maybe</a>s and
--   returns a list of all the <a>Just</a> values.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; catMaybes [Just 1, Nothing, Just 3]
--   [1,3]
--   </pre>
--   
--   When constructing a list of <a>Maybe</a> values, <a>catMaybes</a> can
--   be used to return all of the "success" results (if the list is the
--   result of a <a>map</a>, then <a>mapMaybe</a> would be more
--   appropriate):
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
--   [Just 1,Nothing,Just 3]
--   
--   &gt;&gt;&gt; catMaybes $ [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
--   [1,3]
--   </pre>
catMaybes :: () => [Maybe a] -> [a]

-- | The <a>listToMaybe</a> function returns <a>Nothing</a> on an empty
--   list or <tt><a>Just</a> a</tt> where <tt>a</tt> is the first element
--   of the list.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; listToMaybe []
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; listToMaybe [9]
--   Just 9
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; listToMaybe [1,2,3]
--   Just 1
--   </pre>
--   
--   Composing <a>maybeToList</a> with <a>listToMaybe</a> should be the
--   identity on singleton/empty lists:
--   
--   <pre>
--   &gt;&gt;&gt; maybeToList $ listToMaybe [5]
--   [5]
--   
--   &gt;&gt;&gt; maybeToList $ listToMaybe []
--   []
--   </pre>
--   
--   But not on lists with more than one element:
--   
--   <pre>
--   &gt;&gt;&gt; maybeToList $ listToMaybe [1,2,3]
--   [1]
--   </pre>
listToMaybe :: () => [a] -> Maybe a

-- | The <a>maybeToList</a> function returns an empty list when given
--   <a>Nothing</a> or a singleton list when not given <a>Nothing</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; maybeToList (Just 7)
--   [7]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; maybeToList Nothing
--   []
--   </pre>
--   
--   One can use <a>maybeToList</a> to avoid pattern matching when combined
--   with a function that (safely) works on lists:
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; sum $ maybeToList (readMaybe "3")
--   3
--   
--   &gt;&gt;&gt; sum $ maybeToList (readMaybe "")
--   0
--   </pre>
maybeToList :: () => Maybe a -> [a]

-- | The <a>fromMaybe</a> function takes a default value and and
--   <a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns
--   the default values; otherwise, it returns the value contained in the
--   <a>Maybe</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; fromMaybe "" Nothing
--   ""
--   </pre>
--   
--   Read an integer from a string using <tt>readMaybe</tt>. If we fail to
--   parse an integer, we want to return <tt>0</tt> by default:
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; fromMaybe 0 (readMaybe "5")
--   5
--   
--   &gt;&gt;&gt; fromMaybe 0 (readMaybe "")
--   0
--   </pre>
fromMaybe :: () => a -> Maybe a -> a

-- | The <a>fromJust</a> function extracts the element out of a <a>Just</a>
--   and throws an error if its argument is <a>Nothing</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; fromJust (Just 1)
--   1
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 2 * (fromJust (Just 10))
--   20
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; 2 * (fromJust Nothing)
--   *** Exception: Maybe.fromJust: Nothing
--   </pre>
fromJust :: () => Maybe a -> a

-- | The <a>isNothing</a> function returns <a>True</a> iff its argument is
--   <a>Nothing</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; isNothing (Just 3)
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isNothing (Just ())
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isNothing Nothing
--   True
--   </pre>
--   
--   Only the outer constructor is taken into consideration:
--   
--   <pre>
--   &gt;&gt;&gt; isNothing (Just Nothing)
--   False
--   </pre>
isNothing :: () => Maybe a -> Bool

-- | The <a>isJust</a> function returns <a>True</a> iff its argument is of
--   the form <tt>Just _</tt>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; isJust (Just 3)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isJust (Just ())
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; isJust Nothing
--   False
--   </pre>
--   
--   Only the outer constructor is taken into consideration:
--   
--   <pre>
--   &gt;&gt;&gt; isJust (Just Nothing)
--   True
--   </pre>
isJust :: () => Maybe a -> Bool

-- | The <a>maybe</a> function takes a default value, a function, and a
--   <a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the
--   function returns the default value. Otherwise, it applies the function
--   to the value inside the <a>Just</a> and returns the result.
--   
--   <h4><b>Examples</b></h4>
--   
--   Basic usage:
--   
--   <pre>
--   &gt;&gt;&gt; maybe False odd (Just 3)
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; maybe False odd Nothing
--   False
--   </pre>
--   
--   Read an integer from a string using <tt>readMaybe</tt>. If we succeed,
--   return twice the integer; that is, apply <tt>(*2)</tt> to it. If
--   instead we fail to parse an integer, return <tt>0</tt> by default:
--   
--   <pre>
--   &gt;&gt;&gt; import Text.Read ( readMaybe )
--   
--   &gt;&gt;&gt; maybe 0 (*2) (readMaybe "5")
--   10
--   
--   &gt;&gt;&gt; maybe 0 (*2) (readMaybe "")
--   0
--   </pre>
--   
--   Apply <tt>show</tt> to a <tt>Maybe Int</tt>. If we have <tt>Just
--   n</tt>, we want to show the underlying <a>Int</a> <tt>n</tt>. But if
--   we have <a>Nothing</a>, we return the empty string instead of (for
--   example) "Nothing":
--   
--   <pre>
--   &gt;&gt;&gt; maybe "" show (Just 5)
--   "5"
--   
--   &gt;&gt;&gt; maybe "" show Nothing
--   ""
--   </pre>
maybe :: () => b -> a -> b -> Maybe a -> b

-- | <a>uncurry</a> converts a curried function to a function on pairs.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; uncurry (+) (1,2)
--   3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; uncurry ($) (show, 1)
--   "1"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; map (uncurry max) [(1,2), (3,4), (6,8)]
--   [2,4,8]
--   </pre>
uncurry :: () => a -> b -> c -> (a, b) -> c

-- | <a>curry</a> converts an uncurried function to a curried function.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; curry fst 1 2
--   1
--   </pre>
curry :: () => (a, b) -> c -> a -> b -> c

-- | the same as <tt><a>flip</a> (<a>-</a>)</tt>.
--   
--   Because <tt>-</tt> is treated specially in the Haskell grammar,
--   <tt>(-</tt> <i>e</i><tt>)</tt> is not a section, but an application of
--   prefix negation. However, <tt>(<a>subtract</a></tt>
--   <i>exp</i><tt>)</tt> is equivalent to the disallowed section.
subtract :: Num a => a -> a -> a

-- | <a>asTypeOf</a> is a type-restricted version of <a>const</a>. It is
--   usually used as an infix operator, and its typing forces its first
--   argument (which is usually overloaded) to have the same type as the
--   second.
asTypeOf :: () => a -> a -> a

-- | <tt><a>until</a> p f</tt> yields the result of applying <tt>f</tt>
--   until <tt>p</tt> holds.
until :: () => a -> Bool -> a -> a -> a -> a

-- | Strict (call-by-value) application operator. It takes a function and
--   an argument, evaluates the argument to weak head normal form (WHNF),
--   then calls the function with that value.
($!) :: () => a -> b -> a -> b
infixr 0 $!

-- | <tt><a>flip</a> f</tt> takes its (first) two arguments in the reverse
--   order of <tt>f</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; flip (++) "hello" "world"
--   "worldhello"
--   </pre>
flip :: () => a -> b -> c -> b -> a -> c

-- | Function composition.
(.) :: () => b -> c -> a -> b -> a -> c
infixr 9 .

-- | <tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for
--   all inputs.
--   
--   <pre>
--   &gt;&gt;&gt; const 42 "hello"
--   42
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; map (const 42) [0..3]
--   [42,42,42,42]
--   </pre>
const :: () => a -> b -> a

-- | Identity function.
--   
--   <pre>
--   id x = x
--   </pre>
id :: () => a -> a

-- | In many situations, the <a>liftM</a> operations can be replaced by
--   uses of <a>ap</a>, which promotes function application.
--   
--   <pre>
--   return f `ap` x1 `ap` ... `ap` xn
--   </pre>
--   
--   is equivalent to
--   
--   <pre>
--   liftMn f x1 x2 ... xn
--   </pre>
ap :: Monad m => m a -> b -> m a -> m b

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. <a>liftM2</a>).
liftM5 :: Monad m => a1 -> a2 -> a3 -> a4 -> a5 -> r -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. <a>liftM2</a>).
liftM4 :: Monad m => a1 -> a2 -> a3 -> a4 -> r -> m a1 -> m a2 -> m a3 -> m a4 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right (cf. <a>liftM2</a>).
liftM3 :: Monad m => a1 -> a2 -> a3 -> r -> m a1 -> m a2 -> m a3 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
--   left to right. For example,
--   
--   <pre>
--   liftM2 (+) [0,1] [0,2] = [0,2,1,3]
--   liftM2 (+) (Just 1) Nothing = Nothing
--   </pre>
liftM2 :: Monad m => a1 -> a2 -> r -> m a1 -> m a2 -> m r

-- | Promote a function to a monad.
liftM :: Monad m => a1 -> r -> m a1 -> m r

-- | Conditional execution of <a>Applicative</a> expressions. For example,
--   
--   <pre>
--   when debug (putStrLn "Debugging")
--   </pre>
--   
--   will output the string <tt>Debugging</tt> if the Boolean value
--   <tt>debug</tt> is <a>True</a>, and otherwise do nothing.
when :: Applicative f => Bool -> f () -> f ()

-- | Same as <a>&gt;&gt;=</a>, but with the arguments interchanged.
(=<<) :: Monad m => a -> m b -> m a -> m b
infixr 1 =<<

-- | A special case of <a>error</a>. It is expected that compilers will
--   recognize this and insert error messages which are more appropriate to
--   the context in which <a>undefined</a> appears.
undefined :: HasCallStack => a

-- | A variant of <a>error</a> that does not produce a stack trace.
errorWithoutStackTrace :: () => [Char] -> a

-- | <a>error</a> stops execution and displays an error message.
error :: HasCallStack => [Char] -> a

-- | Boolean "and"
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

-- | Boolean "or"
(||) :: Bool -> Bool -> Bool
infixr 2 ||

-- | Boolean "not"
not :: Bool -> Bool

-- | Simplification of the <a>MarkupM</a> datatype.
type Markup = MarkupM ()

-- | Convert a value to Markup without escaping
preEscapedToMarkup :: ToMarkup a => a -> Markup
toHtml :: ToMarkup a => a -> Html
type Html = Markup

-- | Monads which allow their actions to be run in <a>IO</a>.
--   
--   While <a>MonadIO</a> allows an <a>IO</a> action to be lifted into
--   another monad, this class captures the opposite concept: allowing you
--   to capture the monadic context. Note that, in order to meet the laws
--   given below, the intuition is that a monad must have no monadic state,
--   but may have monadic context. This essentially limits
--   <a>MonadUnliftIO</a> to <a>ReaderT</a> and <a>IdentityT</a>
--   transformers on top of <a>IO</a>.
--   
--   Laws. For any value <tt>u</tt> returned by <a>askUnliftIO</a>, it must
--   meet the monad transformer laws as reformulated for
--   <tt>MonadUnliftIO</tt>:
--   
--   <ul>
--   <li><pre>unliftIO u . return = return</pre></li>
--   <li><pre>unliftIO u (m &gt;&gt;= f) = unliftIO u m &gt;&gt;= unliftIO
--   u . f</pre></li>
--   </ul>
--   
--   The third is a currently nameless law which ensures that the current
--   context is preserved.
--   
--   <ul>
--   <li><pre>askUnliftIO &gt;&gt;= (u -&gt; liftIO (unliftIO u m)) =
--   m</pre></li>
--   </ul>
--   
--   If you have a name for this, please submit it in a pull request for
--   great glory.
class MonadIO m => MonadUnliftIO (m :: * -> *)

-- | Capture the current monadic context, providing the ability to run
--   monadic actions in <a>IO</a>.
--   
--   See <a>UnliftIO</a> for an explanation of why we need a helper
--   datatype here.
askUnliftIO :: MonadUnliftIO m => m UnliftIO m

-- | Convenience function for capturing the monadic context and running an
--   <a>IO</a> action with a runner function. The runner function is used
--   to run a monadic action <tt>m</tt> in <tt>IO</tt>.
withRunInIO :: MonadUnliftIO m => forall a. () => m a -> IO a -> IO b -> m b

-- | A <tt>Monad</tt> which allows for safe resource allocation. In theory,
--   any monad transformer stack which includes a <tt>ResourceT</tt> can be
--   an instance of <tt>MonadResource</tt>.
--   
--   Note: <tt>runResourceT</tt> has a requirement for a <tt>MonadUnliftIO
--   m</tt> monad, which allows control operations to be lifted. A
--   <tt>MonadResource</tt> does not have this requirement. This means that
--   transformers such as <tt>ContT</tt> can be an instance of
--   <tt>MonadResource</tt>. However, the <tt>ContT</tt> wrapper will need
--   to be unwrapped before calling <tt>runResourceT</tt>.
--   
--   Since 0.3.0
class MonadIO m => MonadResource (m :: * -> *)

-- | Lift a <tt>ResourceT IO</tt> action into the current <tt>Monad</tt>.
--   
--   Since 0.4.0
liftResourceT :: MonadResource m => ResourceT IO a -> m a

-- | The class of monad transformers. Instances should satisfy the
--   following laws, which state that <a>lift</a> is a monad
--   transformation:
--   
--   <ul>
--   <li><pre><a>lift</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>lift</a> (m &gt;&gt;= f) = <a>lift</a> m &gt;&gt;=
--   (<a>lift</a> . f)</pre></li>
--   </ul>
class MonadTrans (t :: * -> * -> * -> *)

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, Monad m) => m a -> t m a

-- | This is a length of time, as measured by a clock. Conversion functions
--   will treat it as seconds. It has a precision of 10^-12 s.
data DiffTime

-- | A class for types with a default value.
class Default a

-- | The default value for this type.
def :: Default a => a

-- | Generates a function that takes a <a>LogSource</a>, a level name and a
--   <a>Text</a> and logs a <a>LevelOther</a> message. Usage:
--   
--   <pre>
--   $logOtherS "SomeSource" "My new level" "This is a log message"
--   </pre>
logOtherS :: Q Exp

-- | See <a>logDebugS</a>
logErrorS :: Q Exp

-- | See <a>logDebugS</a>
logWarnS :: Q Exp

-- | See <a>logDebugS</a>
logInfoS :: Q Exp

-- | Generates a function that takes a <a>LogSource</a> and <a>Text</a> and
--   logs a <a>LevelDebug</a> message. Usage:
--   
--   <pre>
--   $logDebugS "SomeSource" "This is a debug log message"
--   </pre>
logDebugS :: Q Exp

-- | Generates a function that takes a <a>Text</a> and logs a
--   <a>LevelOther</a> message. Usage:
--   
--   <pre>
--   $(logOther "My new level") "This is a log message"
--   </pre>
logOther :: Text -> Q Exp

-- | See <a>logDebug</a>
logError :: Q Exp

-- | See <a>logDebug</a>
logWarn :: Q Exp

-- | See <a>logDebug</a>
logInfo :: Q Exp

-- | Generates a function that takes a <a>Text</a> and logs a
--   <a>LevelDebug</a> message. Usage:
--   
--   <pre>
--   $(logDebug) "This is a debug log message"
--   </pre>
logDebug :: Q Exp
data LogLevel
LevelDebug :: LogLevel
LevelInfo :: LogLevel
LevelWarn :: LogLevel
LevelError :: LogLevel
LevelOther :: Text -> LogLevel

-- | A <tt>Monad</tt> which has the ability to log messages in some manner.
class Monad m => MonadLogger (m :: * -> *)
class PathPiece s
fromPathPiece :: PathPiece s => Text -> Maybe s
toPathPiece :: PathPiece s => s -> Text
class PathMultiPiece s
fromPathMultiPiece :: PathMultiPiece s => [Text] -> Maybe s
toPathMultiPiece :: PathMultiPiece s => s -> [Text]

-- | FIXME What's this exactly?
limitOffsetOrder :: PersistEntity val => [SelectOpt val] -> (Int, Int, [SelectOpt val])

-- | A more general way to convert instances of <a>ToJSON</a> type class to
--   strict text <a>Text</a>.
toJsonText :: ToJSON j => j -> Text

-- | Convert map (list of tuples) into textual representation of JSON
--   object. This is a type-constrained synonym for <a>toJsonText</a>.
mapToJSON :: [(Text, PersistValue)] -> Text

-- | Convert list of <a>PersistValue</a>s into textual representation of
--   JSON object. This is a type-constrained synonym for <a>toJsonText</a>.
listToJSON :: [PersistValue] -> Text

-- | The OR of two lists of filters. For example:
--   
--   <pre>
--   selectList
--       ([ PersonAge &gt;. 25
--        , PersonAge &lt;. 30 ] ||.
--        [ PersonIncome &gt;. 15000
--        , PersonIncome &lt;. 25000 ])
--       []
--   </pre>
--   
--   will filter records where a person's age is between 25 and 30
--   <i>or</i> a person's income is between (15000 and 25000).
--   
--   If you are looking for an <tt>(&amp;&amp;.)</tt> operator to do <tt>(A
--   AND B AND (C OR D))</tt> you can use the <tt>(++)</tt> operator
--   instead as there is no <tt>(&amp;&amp;.)</tt>. For example:
--   
--   <pre>
--   selectList
--       ([ PersonAge &gt;. 25
--        , PersonAge &lt;. 30 ] ++
--       ([PersonCategory ==. 1] ||.
--        [PersonCategory ==. 5]))
--       []
--   </pre>
--   
--   will filter records where a person's age is between 25 and 30
--   <i>and</i> (person's category is either 1 or 5).
(||.) :: () => [Filter v] -> [Filter v] -> [Filter v]
infixl 3 ||.

-- | Check if value is not in given list.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectSimon :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectSimon = selectList [UserAge /&lt;-. [40]] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |2    |Simon|41   |
--   +-----+-----+-----+
--   </pre>
(/<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v
infix 4 /<-.

-- | Check if value is in given list.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectUsers :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectUsers = selectList [UserAge &lt;-. [40, 41]] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |1    |SPJ  |40   |
--   +-----+-----+-----+
--   |2    |Simon|41   |
--   +-----+-----+-----+
--   </pre>
--   
--   <pre>
--   selectSPJ :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectSPJ = selectList [UserAge &lt;-. [40]] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |1    |SPJ  |40   |
--   +-----+-----+-----+
--   </pre>
(<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v
infix 4 <-.

-- | Greater-than or equal check.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectGreaterEqualAge :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectGreaterEqualAge = selectList [UserAge &gt;=. 41 ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |2    |Simon|41   |
--   +-----+-----+-----+
--   </pre>
(>=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 >=.

-- | Greater-than check.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectGreaterAge :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectGreaterAge = selectList [UserAge &gt;. 40 ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |2    |Simon|41   |
--   +-----+-----+-----+
--   </pre>
(>.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 >.

-- | Less-than or equal check.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectLessEqualAge :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectLessEqualAge = selectList [UserAge &lt;=. 40 ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |1    |SPJ  |40   |
--   +-----+-----+-----+
--   </pre>
(<=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 <=.

-- | Less-than check.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectLessAge :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectLessAge = selectList [UserAge &lt;. 41 ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |1    |SPJ  |40   |
--   +-----+-----+-----+
--   </pre>
(<.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 <.

-- | Non-equality check.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectSimon :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectSimon = selectList [UserName !=. "SPJ" ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |2    |Simon|41   |
--   +-----+-----+-----+
--   </pre>
(!=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 !=.

-- | Check for equality.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   selectSPJ :: MonadIO m =&gt; ReaderT SqlBackend m [Entity User]
--   selectSPJ = selectList [UserName ==. "SPJ" ] []
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+-----+
--   |id   |name |age  |
--   +-----+-----+-----+
--   |1    |SPJ  |40   |
--   +-----+-----+-----+
--   </pre>
(==.) :: PersistField typ => EntityField v typ -> typ -> Filter v
infix 4 ==.

-- | Assign a field by division (<tt>/=</tt>).
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   divideAge :: MonadIO m =&gt; ReaderT SqlBackend m ()
--   divideAge = updateWhere [UserName ==. "SPJ" ] [UserAge /=. 2]
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+---------+
--   |id   |name |age      |
--   +-----+-----+---------+
--   |1    |SPJ  |40 -&gt; 20 |
--   +-----+-----+---------+
--   |2    |Simon|41       |
--   +-----+-----+---------+
--   </pre>
(/=.) :: PersistField typ => EntityField v typ -> typ -> Update v
infixr 3 /=.

-- | Assign a field by multiplication (<tt>*=</tt>).
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   multiplyAge :: MonadIO m =&gt; ReaderT SqlBackend m ()
--   multiplyAge = updateWhere [UserName ==. "SPJ" ] [UserAge *=. 2]
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+--------+
--   |id   |name |age     |
--   +-----+-----+--------+
--   |1    |SPJ  |40 -&gt; 80|
--   +-----+-----+--------+
--   |2    |Simon|41      |
--   +-----+-----+--------+
--   </pre>
(*=.) :: PersistField typ => EntityField v typ -> typ -> Update v
infixr 3 *=.

-- | Assign a field by subtraction (<tt>-=</tt>).
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   subtractAge :: MonadIO m =&gt; ReaderT SqlBackend m ()
--   subtractAge = updateWhere [UserName ==. "SPJ" ] [UserAge -=. 1]
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+---------+
--   |id   |name |age      |
--   +-----+-----+---------+
--   |1    |SPJ  |40 -&gt; 39 |
--   +-----+-----+---------+
--   |2    |Simon|41       |
--   +-----+-----+---------+
--   </pre>
(-=.) :: PersistField typ => EntityField v typ -> typ -> Update v
infixr 3 -=.

-- | Assign a field by addition (<tt>+=</tt>).
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   addAge :: MonadIO m =&gt; ReaderT SqlBackend m ()
--   addAge = updateWhere [UserName ==. "SPJ" ] [UserAge +=. 1]
--   </pre>
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+---------+
--   |id   |name |age      |
--   +-----+-----+---------+
--   |1    |SPJ  |40 -&gt; 41 |
--   +-----+-----+---------+
--   |2    |Simon|41       |
--   +-----+-----+---------+
--   </pre>
(+=.) :: PersistField typ => EntityField v typ -> typ -> Update v
infixr 3 +=.

-- | Assign a field a value.
--   
--   <h3><b>Example usage</b></h3>
--   
--   <pre>
--   updateAge :: MonadIO m =&gt; ReaderT SqlBackend m ()
--   updateAge = updateWhere [UserName ==. "SPJ" ] [UserAge =. 45]
--   </pre>
--   
--   Similar to <a>updateWhere</a> which is shown in the above example you
--   can use other functions present in the module
--   <a>Database.Persist.Class</a>. Note that the first parameter of
--   <a>updateWhere</a> is [<a>Filter</a> val] and second parameter is
--   [<a>Update</a> val]. By comparing this with the type of <a>==.</a> and
--   <a>=.</a>, you can see that they match up in the above usage.
--   
--   The above query when applied on <a>dataset-1</a>, will produce this:
--   
--   <pre>
--   +-----+-----+--------+
--   |id   |name |age     |
--   +-----+-----+--------+
--   |1    |SPJ  |40 -&gt; 45|
--   +-----+-----+--------+
--   |2    |Simon|41      |
--   +-----+-----+--------+
--   </pre>
(=.) :: PersistField typ => EntityField v typ -> typ -> Update v
infixr 3 =.

-- | A backwards-compatible alias for those that don't care about
--   distinguishing between read and write queries. It signifies the
--   assumption that, by default, a backend can write as well as read.
type PersistUnique a = PersistUniqueWrite a

-- | A backwards-compatible alias for those that don't care about
--   distinguishing between read and write queries. It signifies the
--   assumption that, by default, a backend can write as well as read.
type PersistQuery a = PersistQueryWrite a

-- | A backwards-compatible alias for those that don't care about
--   distinguishing between read and write queries. It signifies the
--   assumption that, by default, a backend can write as well as read.
type PersistStore a = PersistStoreWrite a

-- | Cascade-deletion of entries satisfying given filters.
deleteCascadeWhere :: (MonadIO m, DeleteCascade record backend, PersistQueryWrite backend) => [Filter record] -> ReaderT backend m ()

-- | For combinations of backends and entities that support
--   cascade-deletion. “Cascade-deletion” means that entries that depend on
--   other entries to be deleted will be deleted as well.
class (PersistStoreWrite backend, PersistEntity record, BaseBackend backend ~ PersistEntityBackend record) => DeleteCascade record backend

-- | Perform cascade-deletion of single database entry.
deleteCascade :: (DeleteCascade record backend, MonadIO m) => Key record -> ReaderT backend m ()

-- | Call <a>selectKeys</a> but return the result as a list.
selectKeysList :: (MonadIO m, PersistQueryRead backend, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m [Key record]

-- | Call <a>selectSource</a> but return the result as a list.
selectList :: (MonadIO m, PersistQueryRead backend, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m [Entity record]

-- | Get the <a>Key</a>s of all records matching the given criterion.
selectKeys :: (PersistQueryRead BaseBackend backend, MonadResource m, PersistEntity record, BaseBackend BaseBackend backend ~ PersistEntityBackend record, MonadReader backend m, HasPersistBackend backend) => [Filter record] -> [SelectOpt record] -> ConduitM () Key record m ()

-- | Get all records matching the given criterion in the specified order.
--   Returns also the identifiers.
selectSource :: (PersistQueryRead BaseBackend backend, MonadResource m, PersistEntity record, PersistEntityBackend record ~ BaseBackend BaseBackend backend, MonadReader backend m, HasPersistBackend backend) => [Filter record] -> [SelectOpt record] -> ConduitM () Entity record m ()

-- | Backends supporting conditional read operations.
class (PersistCore backend, PersistStoreRead backend) => PersistQueryRead backend

-- | Get all records matching the given criterion in the specified order.
--   Returns also the identifiers.
selectSourceRes :: (PersistQueryRead backend, PersistRecordBackend record backend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 Acquire ConduitM () Entity record m2 ()

-- | Get just the first record for the criterion.
selectFirst :: (PersistQueryRead backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m Maybe Entity record

-- | Get the <a>Key</a>s of all records matching the given criterion.
selectKeysRes :: (PersistQueryRead backend, MonadIO m1, MonadIO m2, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 Acquire ConduitM () Key record m2 ()

-- | The total number of records fulfilling the given criterion.
count :: (PersistQueryRead backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m Int

-- | Backends supporting conditional write operations
class (PersistQueryRead backend, PersistStoreWrite backend) => PersistQueryWrite backend

-- | Update individual fields on any record matching the given criterion.
updateWhere :: (PersistQueryWrite backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [Update record] -> ReaderT backend m ()

-- | Delete all records matching the given criterion.
deleteWhere :: (PersistQueryWrite backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m ()

-- | Check whether there are any conflicts for unique keys with this entity
--   and existing entities in the database.
--   
--   Returns <a>Nothing</a> if the entity would be unique, and could thus
--   safely be inserted. on a conflict returns the conflicting key
checkUnique :: (MonadIO m, PersistRecordBackend record backend, PersistUniqueRead backend) => record -> ReaderT backend m Maybe Unique record

-- | Attempt to replace the record of the given key with the given new
--   record. First query the unique fields to make sure the replacement
--   maintains uniqueness constraints.
--   
--   Return <a>Nothing</a> if the replacement was made. If uniqueness is
--   violated, return a <a>Just</a> with the <a>Unique</a> violation
replaceUnique :: (MonadIO m, Eq record, Eq Unique record, PersistRecordBackend record backend, PersistUniqueWrite backend) => Key record -> record -> ReaderT backend m Maybe Unique record

-- | A modification of <a>getBy</a>, which takes the <a>PersistEntity</a>
--   itself instead of a <a>Unique</a> record. Returns a record matching
--   <i>one</i> of the unique keys. This function makes the most sense on
--   entities with a single <a>Unique</a> constructor.
getByValue :: (MonadIO m, PersistUniqueRead backend, PersistRecordBackend record backend) => record -> ReaderT backend m Maybe Entity record

-- | Return the single unique key for a record.
onlyUnique :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend) => record -> ReaderT backend m Unique record

-- | Like <a>insertEntity</a>, but returns <a>Nothing</a> when the record
--   couldn't be inserted because of a uniqueness constraint.
insertUniqueEntity :: (MonadIO m, PersistRecordBackend record backend, PersistUniqueWrite backend) => record -> ReaderT backend m Maybe Entity record

-- | Insert a value, checking for conflicts with any unique constraints. If
--   a duplicate exists in the database, it is returned as <a>Left</a>.
--   Otherwise, the new 'Key is returned as <a>Right</a>.
insertBy :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend) => record -> ReaderT backend m Either Entity record Key record

-- | Queries against <a>Unique</a> keys (other than the id <a>Key</a>).
--   
--   Please read the general Persistent documentation to learn how to
--   create <a>Unique</a> keys.
--   
--   Using this with an Entity without a Unique key leads to undefined
--   behavior. A few of these functions require a <i>single</i>
--   <a>Unique</a>, so using an Entity with multiple <a>Unique</a>s is also
--   undefined. In these cases persistent's goal is to throw an exception
--   as soon as possible, but persistent is still transitioning to that.
--   
--   SQL backends automatically create uniqueness constraints, but for
--   MongoDB you must manually place a unique index on a field to have a
--   uniqueness constraint.
class (PersistCore backend, PersistStoreRead backend) => PersistUniqueRead backend

-- | Get a record by unique key, if available. Returns also the identifier.
getBy :: (PersistUniqueRead backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m Maybe Entity record

-- | Some functions in this module (<a>insertUnique</a>, <a>insertBy</a>,
--   and <a>replaceUnique</a>) first query the unique indexes to check for
--   conflicts. You could instead optimistically attempt to perform the
--   operation (e.g. <a>replace</a> instead of <a>replaceUnique</a>).
--   However,
--   
--   <ul>
--   <li>there is some fragility to trying to catch the correct exception
--   and determing the column of failure;</li>
--   <li>an exception will automatically abort the current SQL
--   transaction.</li>
--   </ul>
class (PersistUniqueRead backend, PersistStoreWrite backend) => PersistUniqueWrite backend

-- | Delete a specific record by unique key. Does nothing if no record
--   matches.
deleteBy :: (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m ()

-- | Like <a>insert</a>, but returns <a>Nothing</a> when the record
--   couldn't be inserted because of a uniqueness constraint.
insertUnique :: (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m Maybe Key record

-- | Update based on a uniqueness constraint or insert:
--   
--   <ul>
--   <li>insert the new record if it does not exist;</li>
--   <li>If the record exists (matched via it's uniqueness constraint),
--   then update the existing record with the parameters which is passed on
--   as list to the function.</li>
--   </ul>
--   
--   Throws an exception if there is more than 1 uniqueness constraint.
upsert :: (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> [Update record] -> ReaderT backend m Entity record

-- | Update based on a given uniqueness constraint or insert:
--   
--   <ul>
--   <li>insert the new record if it does not exist;</li>
--   <li>update the existing record that matches the given uniqueness
--   constraint.</li>
--   </ul>
upsertBy :: (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> record -> [Update record] -> ReaderT backend m Entity record

-- | Put many records into db
--   
--   <ul>
--   <li>insert new records that do not exist (or violate any unique
--   constraints)</li>
--   <li>replace existing records (matching any unique constraint) @since
--   2.8.1</li>
--   </ul>
putMany :: (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()

-- | Like <a>insertEntity</a> but just returns the record instead of
--   <a>Entity</a>.
insertRecord :: (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStoreWrite backend) => record -> ReaderT backend m record

-- | Like <tt>get</tt>, but returns the complete <tt>Entity</tt>.
getEntity :: (PersistStoreRead backend, PersistRecordBackend e backend, MonadIO m) => Key e -> ReaderT backend m Maybe Entity e

-- | Like <tt>insert</tt>, but returns the complete <tt>Entity</tt>.
insertEntity :: (PersistStoreWrite backend, PersistRecordBackend e backend, MonadIO m) => e -> ReaderT backend m Entity e

-- | Same as <a>belongsTo</a>, but uses <tt>getJust</tt> and therefore is
--   similarly unsafe.
belongsToJust :: (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => ent1 -> Key ent2 -> ent1 -> ReaderT backend m ent2

-- | Curry this to make a convenience function that loads an associated
--   model.
--   
--   <pre>
--   foreign = belongsTo foreignId
--   </pre>
belongsTo :: (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => ent1 -> Maybe Key ent2 -> ent1 -> ReaderT backend m Maybe ent2

-- | Same as <a>getJust</a>, but returns an <a>Entity</a> instead of just
--   the record.
getJustEntity :: (PersistEntityBackend record ~ BaseBackend backend, MonadIO m, PersistEntity record, PersistStoreRead backend) => Key record -> ReaderT backend m Entity record

-- | Same as <a>get</a>, but for a non-null (not Maybe) foreign key. Unsafe
--   unless your database is enforcing that the foreign key is valid.
getJust :: (PersistStoreRead backend, Show Key record, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record
liftPersist :: (MonadIO m, MonadReader backend m, HasPersistBackend backend) => ReaderT BaseBackend backend IO b -> m b

-- | Class which allows the plucking of a <tt>BaseBackend backend</tt> from
--   some larger type. For example, <tt> instance HasPersistBackend
--   (SqlReadBackend, Int) where type BaseBackend (SqlReadBackend, Int) =
--   SqlBackend persistBackend = unSqlReadBackend . fst </tt>
class HasPersistBackend backend where {
    type family BaseBackend backend :: *;
}
persistBackend :: HasPersistBackend backend => backend -> BaseBackend backend

-- | Class which witnesses that <tt>backend</tt> is essentially the same as
--   <tt>BaseBackend backend</tt>. That is, they're isomorphic and
--   <tt>backend</tt> is just some wrapper over <tt>BaseBackend
--   backend</tt>.
class HasPersistBackend backend => IsPersistBackend backend

-- | This class witnesses that two backend are compatible, and that you can
--   convert from the <tt>sub</tt> backend into the <tt>sup</tt> backend.
--   This is similar to the <a>HasPersistBackend</a> and
--   <a>IsPersistBackend</a> classes, but where you don't want to fix the
--   type associated with the <a>PersistEntityBackend</a> of a record.
--   
--   Generally speaking, where you might have:
--   
--   <pre>
--   foo ::
--     ( <a>PersistEntity</a> record
--     , <tt>PeristEntityBackend</tt> record ~ <a>BaseBackend</a> backend
--     , <tt>IsSqlBackend</tt> backend
--     )
--   </pre>
--   
--   this can be replaced with:
--   
--   <pre>
--   foo ::
--     ( <a>PersistEntity</a> record,
--     , <a>PersistEntityBackend</a> record ~ backend
--     , <a>BackendCompatible</a> <tt>SqlBackend</tt> backend
--     )
--   </pre>
--   
--   This works for <tt>SqlReadBackend</tt> because of the <tt>instance
--   <a>BackendCompatible</a> <tt>SqlBackend</tt>
--   <tt>SqlReadBackend</tt></tt>, without needing to go through the
--   <a>BaseBackend</a> type family.
--   
--   Likewise, functions that are currently hardcoded to use
--   <tt>SqlBackend</tt> can be generalized:
--   
--   <pre>
--   -- before:
--   asdf :: <a>ReaderT</a> <tt>SqlBackend</tt> m ()
--   asdf = pure ()
--   
--   -- after:
--   asdf' :: <a>BackendCompatible</a> SqlBackend backend =&gt; ReaderT backend m ()
--   asdf' = withReaderT <a>projectBackend</a> asdf
--   </pre>
class BackendCompatible sup sub
projectBackend :: BackendCompatible sup sub => sub -> sup

-- | A convenient alias for common type signatures
type PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ BaseBackend backend)

-- | <a>ToBackendKey</a> converts a <a>PersistEntity</a> <a>Key</a> into a
--   <a>BackendKey</a> This can be used by each backend to convert between
--   a <a>Key</a> and a plain Haskell type. For Sql, that is done with
--   <tt>toSqlKey</tt> and <tt>fromSqlKey</tt>.
--   
--   By default, a <a>PersistEntity</a> uses the default <a>BackendKey</a>
--   for its Key and is an instance of ToBackendKey
--   
--   A <a>Key</a> that instead uses a custom type will not be an instance
--   of <a>ToBackendKey</a>.
class (PersistEntity record, PersistEntityBackend record ~ backend, PersistCore backend) => ToBackendKey backend record
toBackendKey :: ToBackendKey backend record => Key record -> BackendKey backend
fromBackendKey :: ToBackendKey backend record => BackendKey backend -> Key record
class PersistCore backend where {
    data family BackendKey backend :: *;
}
class (Show BackendKey backend, Read BackendKey backend, Eq BackendKey backend, Ord BackendKey backend, PersistCore backend, PersistField BackendKey backend, ToJSON BackendKey backend, FromJSON BackendKey backend) => PersistStoreRead backend

-- | Get a record by identifier, if available.
get :: (PersistStoreRead backend, MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m Maybe record

-- | Get many records by their respective identifiers, if available.
getMany :: (PersistStoreRead backend, MonadIO m, PersistRecordBackend record backend) => [Key record] -> ReaderT backend m Map Key record record
class (Show BackendKey backend, Read BackendKey backend, Eq BackendKey backend, Ord BackendKey backend, PersistStoreRead backend, PersistField BackendKey backend, ToJSON BackendKey backend, FromJSON BackendKey backend) => PersistStoreWrite backend

-- | Create a new record in the database, returning an automatically
--   created key (in SQL an auto-increment id).
insert :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m Key record

-- | Same as <a>insert</a>, but doesn't return a <tt>Key</tt>.
insert_ :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m ()

-- | Create multiple records in the database and return their <a>Key</a>s.
--   
--   If you don't need the inserted <a>Key</a>s, use <a>insertMany_</a>.
--   
--   The MongoDB and PostgreSQL backends insert all records and retrieve
--   their keys in one database query.
--   
--   The SQLite and MySQL backends use the slow, default implementation of
--   <tt>mapM insert</tt>.
insertMany :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m [Key record]

-- | Same as <a>insertMany</a>, but doesn't return any <a>Key</a>s.
--   
--   The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records
--   in one database query.
insertMany_ :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()

-- | Same as <a>insertMany_</a>, but takes an <a>Entity</a> instead of just
--   a record.
--   
--   Useful when migrating data from one entity to another and want to
--   preserve ids.
--   
--   The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records
--   in one database query.
insertEntityMany :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [Entity record] -> ReaderT backend m ()

-- | Create a new record in the database using the given key.
insertKey :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()

-- | Put the record in the database with the given key. Unlike
--   <a>replace</a>, if a record with the given key does not exist then a
--   new record will be inserted.
repsert :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()

-- | Put many entities into the database.
--   
--   Batch version of <a>repsert</a> for SQL backends.
--   
--   Useful when migrating data from one entity to another and want to
--   preserve ids.
--   
--   Differs from <tt>insertEntityMany</tt> by gracefully skipping
--   pre-existing records matching key(s). @since 2.8.1
repsertMany :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [(Key record, record)] -> ReaderT backend m ()

-- | Replace the record in the database with the given key. Note that the
--   result is undefined if such record does not exist, so you must use
--   'insertKey or <a>repsert</a> in these cases.
replace :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()

-- | Delete a specific record by identifier. Does nothing if record does
--   not exist.
delete :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m ()

-- | Update individual fields on a specific record.
update :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m ()

-- | Update individual fields on a specific record, and retrieve the
--   updated value from the database.
--   
--   Note that this function will throw an exception if the given key is
--   not found in the database.
updateGet :: (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m record

-- | Convenience function for getting a free <a>PersistField</a> instance
--   from a type with JSON instances. The JSON parser used will accept JSON
--   values other that object and arrays. So, if your instance serializes
--   the data to a JSON string, this will still work.
--   
--   Example usage in combination with <a>toPersistValueJSON</a>:
--   
--   <pre>
--   instance PersistField MyData where
--     fromPersistValue = fromPersistValueJSON
--     toPersistValue = toPersistValueJSON
--   </pre>
fromPersistValueJSON :: FromJSON a => PersistValue -> Either Text a

-- | Convenience function for getting a free <a>PersistField</a> instance
--   from a type with JSON instances.
--   
--   Example usage in combination with <a>fromPersistValueJSON</a>:
--   
--   <pre>
--   instance PersistField MyData where
--     fromPersistValue = fromPersistValueJSON
--     toPersistValue = toPersistValueJSON
--   </pre>
toPersistValueJSON :: ToJSON a => a -> PersistValue

-- | Predefined <tt>parseJSON</tt>. The input JSON looks like <tt>{"id": 1,
--   "name": ...}</tt>.
--   
--   The typical usage is:
--   
--   <pre>
--   instance FromJSON (Entity User) where
--       parseJSON = entityIdFromJSON
--   </pre>
entityIdFromJSON :: (PersistEntity record, FromJSON record, FromJSON Key record) => Value -> Parser Entity record

-- | Predefined <tt>toJSON</tt>. The resulting JSON looks like <tt>{"id":
--   1, "name": ...}</tt>.
--   
--   The typical usage is:
--   
--   <pre>
--   instance ToJSON (Entity User) where
--       toJSON = entityIdToJSON
--   </pre>
entityIdToJSON :: (PersistEntity record, ToJSON record, ToJSON Key record) => Entity record -> Value

-- | Predefined <tt>parseJSON</tt>. The input JSON looks like <tt>{"key":
--   1, "value": {"name": ...}}</tt>.
--   
--   The typical usage is:
--   
--   <pre>
--   instance FromJSON (Entity User) where
--       parseJSON = keyValueEntityFromJSON
--   </pre>
keyValueEntityFromJSON :: (PersistEntity record, FromJSON record, FromJSON Key record) => Value -> Parser Entity record

-- | Predefined <tt>toJSON</tt>. The resulting JSON looks like <tt>{"key":
--   1, "value": {"name": ...}}</tt>.
--   
--   The typical usage is:
--   
--   <pre>
--   instance ToJSON (Entity User) where
--       toJSON = keyValueEntityToJSON
--   </pre>
keyValueEntityToJSON :: (PersistEntity record, ToJSON record, ToJSON Key record) => Entity record -> Value

-- | Get list of values corresponding to given entity.
entityValues :: PersistEntity record => Entity record -> [PersistValue]

-- | Persistent serialized Haskell records to the database. A Database
--   <a>Entity</a> (A row in SQL, a document in MongoDB, etc) corresponds
--   to a <a>Key</a> plus a Haskell record.
--   
--   For every Haskell record type stored in the database there is a
--   corresponding <a>PersistEntity</a> instance. An instance of
--   PersistEntity contains meta-data for the record. PersistEntity also
--   helps abstract over different record types. That way the same query
--   interface can return a <a>PersistEntity</a>, with each query returning
--   different types of Haskell records.
--   
--   Some advanced type system capabilities are used to make this process
--   type-safe. Persistent users usually don't need to understand the class
--   associated data and functions.
class (PersistField Key record, ToJSON Key record, FromJSON Key record, Show Key record, Read Key record, Eq Key record, Ord Key record) => PersistEntity record where {
    type family PersistEntityBackend record :: *;
    data family Key record :: *;
    data family EntityField record a :: *;
    data family Unique record :: *;
}

-- | A lower-level key operation.
keyToValues :: PersistEntity record => Key record -> [PersistValue]

-- | A lower-level key operation.
keyFromValues :: PersistEntity record => [PersistValue] -> Either Text Key record

-- | A meta-operation to retrieve the <a>Key</a> <a>EntityField</a>.
persistIdField :: PersistEntity record => EntityField record Key record

-- | Retrieve the <a>EntityDef</a> meta-data for the record.
entityDef :: (PersistEntity record, Monad m) => m record -> EntityDef

-- | Return meta-data for a given <a>EntityField</a>.
persistFieldDef :: PersistEntity record => EntityField record typ -> FieldDef

-- | A meta-operation to get the database fields of a record.
toPersistFields :: PersistEntity record => record -> [SomePersistField]

-- | A lower-level operation to convert from database values to a Haskell
--   record.
fromPersistValues :: PersistEntity record => [PersistValue] -> Either Text record

-- | A meta operation to retrieve all the <a>Unique</a> keys.
persistUniqueKeys :: PersistEntity record => record -> [Unique record]

-- | A lower level operation.
persistUniqueToFieldNames :: PersistEntity record => Unique record -> [(HaskellName, DBName)]

-- | A lower level operation.
persistUniqueToValues :: PersistEntity record => Unique record -> [PersistValue]

-- | Use a <a>PersistField</a> as a lens.
fieldLens :: PersistEntity record => EntityField record field -> forall (f :: * -> *). Functor f => field -> f field -> Entity record -> f Entity record

-- | Updating a database entity.
--   
--   Persistent users use combinators to create these.
data Update record
[Update] :: Update record
[BackendUpdate] :: Update record

-- | Query options.
--   
--   Persistent users use these directly.
data SelectOpt record
[Asc] :: SelectOpt record
[Desc] :: SelectOpt record
[OffsetBy] :: SelectOpt record
[LimitTo] :: SelectOpt record

-- | Filters which are available for <tt>select</tt>, <tt>updateWhere</tt>
--   and <tt>deleteWhere</tt>. Each filter constructor specifies the field
--   being filtered on, the type of comparison applied (equals, not equals,
--   etc) and the argument for the comparison.
--   
--   Persistent users use combinators to create these.
data Filter record
[Filter] :: Filter record

-- | convenient for internal use, not needed for the API
[FilterAnd] :: Filter record
[FilterOr] :: Filter record
[BackendFilter] :: Filter record

-- | Datatype that represents an entity, with both its <a>Key</a> and its
--   Haskell record representation.
--   
--   When using a SQL-based backend (such as SQLite or PostgreSQL), an
--   <a>Entity</a> may take any number of columns depending on how many
--   fields it has. In order to reconstruct your entity on the Haskell
--   side, <tt>persistent</tt> needs all of your entity columns and in the
--   right order. Note that you don't need to worry about this when using
--   <tt>persistent</tt>'s API since everything is handled correctly behind
--   the scenes.
--   
--   However, if you want to issue a raw SQL command that returns an
--   <a>Entity</a>, then you have to be careful with the column order.
--   While you could use <tt>SELECT Entity.* WHERE ...</tt> and that would
--   work most of the time, there are times when the order of the columns
--   on your database is different from the order that <tt>persistent</tt>
--   expects (for example, if you add a new field in the middle of you
--   entity definition and then use the migration code --
--   <tt>persistent</tt> will expect the column to be in the middle, but
--   your DBMS will put it as the last column). So, instead of using a
--   query like the one above, you may use <a>rawSql</a> (from the
--   <a>Database.Persist.GenericSql</a> module) with its /entity selection
--   placeholder/ (a double question mark <tt>??</tt>). Using
--   <tt>rawSql</tt> the query above must be written as <tt>SELECT ?? WHERE
--   ..</tt>. Then <tt>rawSql</tt> will replace <tt>??</tt> with the list
--   of all columns that we need from your entity in the right order. If
--   your query returns two entities (i.e. <tt>(Entity backend a, Entity
--   backend b)</tt>), then you must you use <tt>SELECT ??, ?? WHERE
--   ...</tt>, and so on.
data Entity record
Entity :: Key record -> record -> Entity record
[entityKey] :: Entity record -> Key record
[entityVal] :: Entity record -> record

-- | FIXME Add documentation to that.
getPersistMap :: PersistValue -> Either Text [(Text, PersistValue)]

-- | This class teaches Persistent how to take a custom type and marshal it
--   to and from a <a>PersistValue</a>, allowing it to be stored in a
--   database.
--   
--   <h4><b>Examples</b></h4>
--   
--   <h5>Simple Newtype</h5>
--   
--   You can use <tt>newtype</tt> to add more type safety/readability to a
--   basis type like <a>ByteString</a>. In these cases, just derive
--   <a>PersistField</a> and <tt>PersistFieldSql</tt>:
--   
--   <pre>
--   {-# LANGUAGE GeneralizedNewtypeDeriving #-}
--   
--   newtype HashedPassword = HashedPassword <a>ByteString</a>
--     deriving (Eq, Show, <a>PersistField</a>, PersistFieldSql)
--   </pre>
--   
--   <h5>Smart Constructor Newtype</h5>
--   
--   In this example, we create a <a>PersistField</a> instance for a
--   newtype following the "Smart Constructor" pattern.
--   
--   <pre>
--   {-# LANGUAGE GeneralizedNewtypeDeriving #-}
--   import qualified <a>Data.Text</a> as T
--   import qualified <a>Data.Char</a> as C
--   
--   -- | An American Social Security Number
--   newtype SSN = SSN <a>Text</a>
--    deriving (Eq, Show, PersistFieldSql)
--   
--   mkSSN :: <a>Text</a> -&gt; <a>Either</a> <a>Text</a> SSN
--   mkSSN t = if (T.length t == 9) &amp;&amp; (T.all C.isDigit t)
--    then <a>Right</a> $ SSN t
--    else <a>Left</a> $ "Invalid SSN: " &lt;&gt; t
--   
--   instance <a>PersistField</a> SSN where
--     <a>toPersistValue</a> (SSN t) = <a>PersistText</a> t
--     <a>fromPersistValue</a> (<a>PersistText</a> t) = mkSSN t
--     -- Handle cases where the database does not give us PersistText
--     <a>fromPersistValue</a> x = <a>Left</a> $ "File.hs: When trying to deserialize an SSN: expected PersistText, received: " &lt;&gt; T.pack (show x)
--   </pre>
--   
--   Tips:
--   
--   <ul>
--   <li>This file contain dozens of <a>PersistField</a> instances you can
--   look at for examples.</li>
--   <li>Typically custom <a>PersistField</a> instances will only accept a
--   single <a>PersistValue</a> constructor in
--   <a>fromPersistValue</a>.</li>
--   <li>Internal <a>PersistField</a> instances accept a wide variety of
--   <a>PersistValue</a>s to accomodate e.g. storing booleans as integers,
--   booleans or strings.</li>
--   <li>If you're making a custom instance and using a SQL database,
--   you'll also need <tt>PersistFieldSql</tt> to specify the type of the
--   database column.</li>
--   </ul>
class PersistField a
toPersistValue :: PersistField a => a -> PersistValue
fromPersistValue :: PersistField a => PersistValue -> Either Text a
data SomePersistField
[SomePersistField] :: SomePersistField
fromPersistValueText :: PersistValue -> Either Text Text
toEmbedEntityDef :: EntityDef -> EmbedEntityDef
keyAndEntityFields :: EntityDef -> [FieldDef]
entityKeyFields :: EntityDef -> [FieldDef]
entityPrimary :: EntityDef -> Maybe CompositeDef

-- | A <a>Checkmark</a> should be used as a field type whenever a
--   uniqueness constraint should guarantee that a certain kind of record
--   may appear at most once, but other kinds of records may appear any
--   number of times.
--   
--   <i>NOTE:</i> You need to mark any <tt>Checkmark</tt> fields as
--   <tt>nullable</tt> (see the following example).
--   
--   For example, suppose there's a <tt>Location</tt> entity that
--   represents where a user has lived:
--   
--   <pre>
--   Location
--       user    UserId
--       name    Text
--       current Checkmark nullable
--   
--       UniqueLocation user current
--   </pre>
--   
--   The <tt>UniqueLocation</tt> constraint allows any number of
--   <a>Inactive</a> <tt>Location</tt>s to be <tt>current</tt>. However,
--   there may be at most one <tt>current</tt> <tt>Location</tt> per user
--   (i.e., either zero or one per user).
--   
--   This data type works because of the way that SQL treats
--   <tt>NULL</tt>able fields within uniqueness constraints. The SQL
--   standard says that <tt>NULL</tt> values should be considered
--   different, so we represent <a>Inactive</a> as SQL <tt>NULL</tt>, thus
--   allowing any number of <a>Inactive</a> records. On the other hand, we
--   represent <a>Active</a> as <tt>TRUE</tt>, so the uniqueness constraint
--   will disallow more than one <a>Active</a> record.
--   
--   <i>Note:</i> There may be DBMSs that do not respect the SQL standard's
--   treatment of <tt>NULL</tt> values on uniqueness constraints, please
--   check if this data type works before relying on it.
--   
--   The SQL <tt>BOOLEAN</tt> type is used because it's the smallest data
--   type available. Note that we never use <tt>FALSE</tt>, just
--   <tt>TRUE</tt> and <tt>NULL</tt>. Provides the same behavior <tt>Maybe
--   ()</tt> would if <tt>()</tt> was a valid <tt>PersistField</tt>.
data Checkmark

-- | When used on a uniqueness constraint, there may be at most one
--   <a>Active</a> record.
Active :: Checkmark

-- | When used on a uniqueness constraint, there may be any number of
--   <a>Inactive</a> records.
Inactive :: Checkmark
data IsNullable
Nullable :: !WhyNullable -> IsNullable
NotNullable :: IsNullable

-- | The reason why a field is <tt>nullable</tt> is very important. A field
--   that is nullable because of a <tt>Maybe</tt> tag will have its type
--   changed from <tt>A</tt> to <tt>Maybe A</tt>. OTOH, a field that is
--   nullable because of a <tt>nullable</tt> tag will remain with the same
--   type.
data WhyNullable
ByMaybeAttr :: WhyNullable
ByNullableAttr :: WhyNullable
data EntityDef
EntityDef :: !HaskellName -> !DBName -> !FieldDef -> ![Attr] -> ![FieldDef] -> ![UniqueDef] -> ![ForeignDef] -> ![Text] -> !Map Text [ExtraLine] -> !Bool -> EntityDef
[entityHaskell] :: EntityDef -> !HaskellName
[entityDB] :: EntityDef -> !DBName
[entityId] :: EntityDef -> !FieldDef
[entityAttrs] :: EntityDef -> ![Attr]
[entityFields] :: EntityDef -> ![FieldDef]
[entityUniques] :: EntityDef -> ![UniqueDef]
[entityForeigns] :: EntityDef -> ![ForeignDef]
[entityDerives] :: EntityDef -> ![Text]
[entityExtra] :: EntityDef -> !Map Text [ExtraLine]
[entitySum] :: EntityDef -> !Bool
type ExtraLine = [Text]
newtype HaskellName
HaskellName :: Text -> HaskellName
[unHaskellName] :: HaskellName -> Text
newtype DBName
DBName :: Text -> DBName
[unDBName] :: DBName -> Text
type Attr = Text
data FieldType

-- | Optional module and name.
FTTypeCon :: Maybe Text -> Text -> FieldType
FTApp :: FieldType -> FieldType -> FieldType
FTList :: FieldType -> FieldType
data FieldDef
FieldDef :: !HaskellName -> !DBName -> !FieldType -> !SqlType -> ![Attr] -> !Bool -> !ReferenceDef -> FieldDef

-- | name of the field
[fieldHaskell] :: FieldDef -> !HaskellName
[fieldDB] :: FieldDef -> !DBName
[fieldType] :: FieldDef -> !FieldType
[fieldSqlType] :: FieldDef -> !SqlType

-- | user annotations for a field
[fieldAttrs] :: FieldDef -> ![Attr]

-- | a strict field in the data type. Default: true
[fieldStrict] :: FieldDef -> !Bool
[fieldReference] :: FieldDef -> !ReferenceDef

-- | There are 3 kinds of references 1) composite (to fields that exist in
--   the record) 2) single field 3) embedded
data ReferenceDef
NoReference :: ReferenceDef

-- | A ForeignRef has a late binding to the EntityDef it references via
--   HaskellName and has the Haskell type of the foreign key in the form of
--   FieldType
ForeignRef :: !HaskellName -> !FieldType -> ReferenceDef
EmbedRef :: EmbedEntityDef -> ReferenceDef
CompositeRef :: CompositeDef -> ReferenceDef

-- | A SelfReference stops an immediate cycle which causes non-termination
--   at compile-time (issue #311).
SelfReference :: ReferenceDef

-- | An EmbedEntityDef is the same as an EntityDef But it is only used for
--   fieldReference so it only has data needed for embedding
data EmbedEntityDef
EmbedEntityDef :: !HaskellName -> ![EmbedFieldDef] -> EmbedEntityDef
[embeddedHaskell] :: EmbedEntityDef -> !HaskellName
[embeddedFields] :: EmbedEntityDef -> ![EmbedFieldDef]

-- | An EmbedFieldDef is the same as a FieldDef But it is only used for
--   embeddedFields so it only has data needed for embedding
data EmbedFieldDef
EmbedFieldDef :: !DBName -> Maybe EmbedEntityDef -> Maybe HaskellName -> EmbedFieldDef
[emFieldDB] :: EmbedFieldDef -> !DBName
[emFieldEmbed] :: EmbedFieldDef -> Maybe EmbedEntityDef

-- | <a>emFieldEmbed</a> can create a cycle (issue #311) when a cycle is
--   detected, <a>emFieldEmbed</a> will be Nothing and <a>emFieldCycle</a>
--   will be Just
[emFieldCycle] :: EmbedFieldDef -> Maybe HaskellName
data UniqueDef
UniqueDef :: !HaskellName -> !DBName -> ![(HaskellName, DBName)] -> ![Attr] -> UniqueDef
[uniqueHaskell] :: UniqueDef -> !HaskellName
[uniqueDBName] :: UniqueDef -> !DBName
[uniqueFields] :: UniqueDef -> ![(HaskellName, DBName)]
[uniqueAttrs] :: UniqueDef -> ![Attr]
data CompositeDef
CompositeDef :: ![FieldDef] -> ![Attr] -> CompositeDef
[compositeFields] :: CompositeDef -> ![FieldDef]
[compositeAttrs] :: CompositeDef -> ![Attr]

-- | Used instead of FieldDef to generate a smaller amount of code
type ForeignFieldDef = (HaskellName, DBName)
data ForeignDef
ForeignDef :: !HaskellName -> !DBName -> !HaskellName -> !DBName -> ![(ForeignFieldDef, ForeignFieldDef)] -> ![Attr] -> Bool -> ForeignDef
[foreignRefTableHaskell] :: ForeignDef -> !HaskellName
[foreignRefTableDBName] :: ForeignDef -> !DBName
[foreignConstraintNameHaskell] :: ForeignDef -> !HaskellName
[foreignConstraintNameDBName] :: ForeignDef -> !DBName
[foreignFields] :: ForeignDef -> ![(ForeignFieldDef, ForeignFieldDef)]
[foreignAttrs] :: ForeignDef -> ![Attr]
[foreignNullable] :: ForeignDef -> Bool
data PersistException

-- | Generic Exception
PersistError :: Text -> PersistException
PersistMarshalError :: Text -> PersistException
PersistInvalidField :: Text -> PersistException
PersistForeignConstraintUnmet :: Text -> PersistException
PersistMongoDBError :: Text -> PersistException
PersistMongoDBUnsupported :: Text -> PersistException

-- | A raw value which can be stored in any backend and can be marshalled
--   to and from a <tt>PersistField</tt>.
data PersistValue
PersistText :: Text -> PersistValue
PersistByteString :: ByteString -> PersistValue
PersistInt64 :: Int64 -> PersistValue
PersistDouble :: Double -> PersistValue
PersistRational :: Rational -> PersistValue
PersistBool :: Bool -> PersistValue
PersistDay :: Day -> PersistValue
PersistTimeOfDay :: TimeOfDay -> PersistValue
PersistUTCTime :: UTCTime -> PersistValue
PersistNull :: PersistValue
PersistList :: [PersistValue] -> PersistValue
PersistMap :: [(Text, PersistValue)] -> PersistValue

-- | Intended especially for MongoDB backend
PersistObjectId :: ByteString -> PersistValue

-- | Using <a>PersistDbSpecific</a> allows you to use types specific to a
--   particular backend For example, below is a simple example of the
--   PostGIS geography type:
--   
--   <pre>
--   data Geo = Geo ByteString
--   
--   instance PersistField Geo where
--     toPersistValue (Geo t) = PersistDbSpecific t
--   
--     fromPersistValue (PersistDbSpecific t) = Right $ Geo $ Data.ByteString.concat ["'", t, "'"]
--     fromPersistValue _ = Left "Geo values must be converted from PersistDbSpecific"
--   
--   instance PersistFieldSql Geo where
--     sqlType _ = SqlOther "GEOGRAPHY(POINT,4326)"
--   
--   toPoint :: Double -&gt; Double -&gt; Geo
--   toPoint lat lon = Geo $ Data.ByteString.concat ["'POINT(", ps $ lon, " ", ps $ lat, ")'"]
--     where ps = Data.Text.pack . show
--   </pre>
--   
--   If Foo has a geography field, we can then perform insertions like the
--   following:
--   
--   <pre>
--   insert $ Foo (toPoint 44 44)
--   </pre>
PersistDbSpecific :: ByteString -> PersistValue

-- | A SQL data type. Naming attempts to reflect the underlying Haskell
--   datatypes, eg SqlString instead of SqlVarchar. Different SQL databases
--   may have different translations for these types.
data SqlType
SqlString :: SqlType
SqlInt32 :: SqlType
SqlInt64 :: SqlType
SqlReal :: SqlType
SqlNumeric :: Word32 -> Word32 -> SqlType
SqlBool :: SqlType
SqlDay :: SqlType
SqlTime :: SqlType

-- | Always uses UTC timezone
SqlDayTime :: SqlType
SqlBlob :: SqlType

-- | a backend-specific name
SqlOther :: Text -> SqlType
data PersistFilter
Eq :: PersistFilter
Ne :: PersistFilter
Gt :: PersistFilter
Lt :: PersistFilter
Ge :: PersistFilter
Le :: PersistFilter
In :: PersistFilter
NotIn :: PersistFilter
BackendSpecificFilter :: Text -> PersistFilter
data UpdateException
KeyNotFound :: String -> UpdateException
UpsertError :: String -> UpdateException
data OnlyUniqueException
OnlyUniqueException :: String -> OnlyUniqueException
data PersistUpdate
Assign :: PersistUpdate
Add :: PersistUpdate
Subtract :: PersistUpdate
Multiply :: PersistUpdate
Divide :: PersistUpdate
BackendSpecificUpdate :: Text -> PersistUpdate

-- | Represents a value containing all the configuration options for a
--   specific backend. This abstraction makes it easier to write code that
--   can easily swap backends.
class PersistConfig c where {
    type family PersistConfigBackend c :: * -> * -> * -> *;
    type family PersistConfigPool c :: *;
}

-- | Load the config settings from a <a>Value</a>, most likely taken from a
--   YAML config file.
loadConfig :: PersistConfig c => Value -> Parser c

-- | Modify the config settings based on environment variables.
applyEnv :: PersistConfig c => c -> IO c

-- | Create a new connection pool based on the given config settings.
createPoolConfig :: PersistConfig c => c -> IO PersistConfigPool c

-- | Run a database action by taking a connection from the pool.
runPool :: (PersistConfig c, MonadUnliftIO m) => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a
packPTH :: String -> Text

-- | Creates a single function to perform all migrations for the entities
--   defined here. One thing to be aware of is dependencies: if you have
--   entities with foreign references, make sure to place those definitions
--   after the entities they reference.
mkMigrate :: String -> [EntityDef] -> Q [Dec]

-- | Automatically creates a valid <a>PersistField</a> instance for any
--   datatype that has valid <a>ToJSON</a> and <a>FromJSON</a> instances.
--   For a datatype <tt>T</tt> it generates instances similar to these:
--   
--   <pre>
--   instance PersistField T where
--       toPersistValue = PersistByteString . L.toStrict . encode
--       fromPersistValue = (left T.pack) . eitherDecodeStrict' &lt;=&lt; fromPersistValue
--   instance PersistFieldSql T where
--       sqlType _ = SqlString
--   </pre>
derivePersistFieldJSON :: String -> Q [Dec]

-- | Automatically creates a valid <a>PersistField</a> instance for any
--   datatype that has valid <a>Show</a> and <a>Read</a> instances. Can be
--   very convenient for <a>Enum</a> types.
derivePersistField :: String -> Q [Dec]

-- | Generate a <a>DeleteCascade</a> instance for the given
--   <tt>EntityDef</tt>s.
mkDeleteCascade :: MkPersistSettings -> [EntityDef] -> Q [Dec]

-- | Save the <tt>EntityDef</tt>s passed in under the given name.
mkSave :: String -> [EntityDef] -> Q [Dec]

-- | Apply the given list of functions to the same <tt>EntityDef</tt>s.
--   
--   This function is useful for cases such as:
--   
--   <pre>
--   &gt;&gt;&gt; share [mkSave "myDefs", mkPersist sqlSettings] [persistLowerCase|...|]
--   </pre>
share :: [[EntityDef] -> Q [Dec]] -> [EntityDef] -> Q [Dec]

-- | produce code similar to the following:
--   
--   <pre>
--   instance PersistEntity e =&gt; PersistField e where
--      toPersistValue = PersistMap $ zip columNames (map toPersistValue . toPersistFields)
--      fromPersistValue (PersistMap o) =
--          let columns = HM.fromList o
--          in fromPersistValues $ map (name -&gt;
--            case HM.lookup name columns of
--              Just v -&gt; v
--              Nothing -&gt; PersistNull
--      fromPersistValue x = Left $ "Expected PersistMap, received: " ++ show x
--      sqlType _ = SqlString
--   </pre>
persistFieldFromEntity :: MkPersistSettings -> EntityDef -> Q [Dec]
lensPTH :: () => s -> a -> s -> b -> t -> Lens s t a b

-- | Same as <a>sqlSettings</a>.
sqlOnlySettings :: MkPersistSettings

-- | Use the <tt>SqlPersist</tt> backend.
sqlSettings :: MkPersistSettings

-- | Create an <tt>MkPersistSettings</tt> with default values.
mkPersistSettings :: Type -> MkPersistSettings

-- | Create data types and appropriate <a>PersistEntity</a> instances for
--   the given <a>EntityDef</a>s. Works well with the persist quasi-quoter.
mkPersist :: MkPersistSettings -> [EntityDef] -> Q [Dec]

parseReferences :: PersistSettings -> Text -> Q Exp

-- | Same as <a>persistFileWith</a>, but uses several external files
--   instead of one. Splitting your Persistent definitions into multiple
--   modules can potentially dramatically speed up compile times.
--   
--   <h4><b>Examples</b></h4>
--   
--   Split your Persistent definitions into multiple files
--   (<tt>models1</tt>, <tt>models2</tt>), then create a new module for
--   each new file and run <a>mkPersist</a> there:
--   
--   <pre>
--   -- Model1.hs
--   <a>share</a>
--       [<a>mkPersist</a> <a>sqlSettings</a>]
--       $(<a>persistFileWith</a> <a>lowerCaseSettings</a> "models1")
--   </pre>
--   
--   <pre>
--   -- Model2.hs
--   <a>share</a>
--       [<a>mkPersist</a> <a>sqlSettings</a>]
--       $(<a>persistFileWith</a> <a>lowerCaseSettings</a> "models2")
--   </pre>
--   
--   Use <a>persistManyFileWith</a> to create your migrations:
--   
--   <pre>
--   -- Migrate.hs
--   <a>share</a>
--       [<a>mkMigrate</a> "migrateAll"]
--       $(<a>persistManyFileWith</a> <a>lowerCaseSettings</a> ["models1","models2"]) 
--   </pre>
--   
--   Tip: To get the same import behavior as if you were declaring all your
--   models in one file, import your new files <tt>as Name</tt> into
--   another file, then export <tt>module Name</tt>.
--   
--   This approach may be used in the future to reduce memory usage during
--   compilation, but so far we've only seen mild reductions.
--   
--   See <a>persistent#778</a> and <a>persistent#791</a> for more details.
persistManyFileWith :: PersistSettings -> [FilePath] -> Q Exp

-- | Same as <a>persistWith</a>, but uses an external file instead of a
--   quasiquotation.
persistFileWith :: PersistSettings -> FilePath -> Q Exp

-- | Apply <a>persistWith</a> to <a>lowerCaseSettings</a>.
persistLowerCase :: QuasiQuoter

-- | Apply <a>persistWith</a> to <a>upperCaseSettings</a>.
persistUpperCase :: QuasiQuoter

-- | Converts a quasi-quoted syntax into a list of entity definitions, to
--   be used as input to the template haskell generation code (mkPersist).
persistWith :: PersistSettings -> QuasiQuoter

-- | Settings to be passed to the <a>mkPersist</a> function.
data MkPersistSettings
data EntityJSON
EntityJSON :: Name -> Name -> EntityJSON

-- | Name of the <tt>toJSON</tt> implementation for <tt>Entity a</tt>.
[entityToJSON] :: EntityJSON -> Name

-- | Name of the <tt>fromJSON</tt> implementation for <tt>Entity a</tt>.
[entityFromJSON] :: EntityJSON -> Name

-- | The Modified Julian Day is a standard count of days, with zero being
--   the day 1858-11-17.
newtype Day
ModifiedJulianDay :: Integer -> Day
[toModifiedJulianDay] :: Day -> Integer
addDays :: Integer -> Day -> Day
diffDays :: Day -> Day -> Integer

-- | Is this year a leap year according to the proleptic Gregorian
--   calendar?
isLeapYear :: Integer -> Bool

-- | Convert to proleptic Gregorian calendar. First element of result is
--   year, second month number (1-12), third day (1-31).
toGregorian :: Day -> (Integer, Int, Int)

-- | Convert from proleptic Gregorian calendar. First argument is year,
--   second month number (1-12), third day (1-31). Invalid values will be
--   clipped to the correct range, month first, then day.
fromGregorian :: Integer -> Int -> Int -> Day

-- | Convert from proleptic Gregorian calendar. First argument is year,
--   second month number (1-12), third day (1-31). Invalid values will
--   return Nothing
fromGregorianValid :: Integer -> Int -> Int -> Maybe Day

-- | Show in ISO 8601 format (yyyy-mm-dd)
showGregorian :: Day -> String

-- | The number of days in a given month according to the proleptic
--   Gregorian calendar. First argument is year, second is month.
gregorianMonthLength :: Integer -> Int -> Int

-- | Add months, with days past the last day of the month clipped to the
--   last day. For instance, 2005-01-30 + 1 month = 2005-02-28.
addGregorianMonthsClip :: Integer -> Day -> Day

-- | Add months, with days past the last day of the month rolling over to
--   the next month. For instance, 2005-01-30 + 1 month = 2005-03-02.
addGregorianMonthsRollOver :: Integer -> Day -> Day

-- | Add years, matching month and day, with Feb 29th clipped to Feb 28th
--   if necessary. For instance, 2004-02-29 + 2 years = 2006-02-28.
addGregorianYearsClip :: Integer -> Day -> Day

-- | Add years, matching month and day, with Feb 29th rolled over to Mar
--   1st if necessary. For instance, 2004-02-29 + 2 years = 2006-03-01.
addGregorianYearsRollOver :: Integer -> Day -> Day

-- | Create a <a>DiffTime</a> which represents an integral number of
--   seconds.
secondsToDiffTime :: Integer -> DiffTime

-- | Create a <a>DiffTime</a> from a number of picoseconds.
picosecondsToDiffTime :: Integer -> DiffTime

-- | Get the number of picoseconds in a <a>DiffTime</a>.
diffTimeToPicoseconds :: DiffTime -> Integer

-- | This is a length of time, as measured by UTC. Conversion functions
--   will treat it as seconds. It has a precision of 10^-12 s. It ignores
--   leap-seconds, so it's not necessarily a fixed amount of clock time.
--   For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1
--   day), regardless of whether a leap-second intervened.
data NominalDiffTime

-- | One day in <a>NominalDiffTime</a>.
nominalDay :: NominalDiffTime

-- | The resolution of <a>getSystemTime</a>, <tt>getCurrentTime</tt>,
--   <tt>getPOSIXTime</tt>
getTime_resolution :: DiffTime

-- | The Modified Julian Date is the day with the fraction of the day,
--   measured from UT midnight. It's used to represent UT1, which is time
--   as measured by the earth's rotation, adjusted for various wobbles.
newtype UniversalTime
ModJulianDate :: Rational -> UniversalTime
[getModJulianDate] :: UniversalTime -> Rational

-- | addUTCTime a b = a + b
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime

-- | diffUTCTime a b = a - b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime

-- | A TimeZone is a whole number of minutes offset from UTC, together with
--   a name and a "just for summer" flag.
data TimeZone
TimeZone :: Int -> Bool -> String -> TimeZone

-- | The number of minutes offset from UTC. Positive means local time will
--   be later in the day than UTC.
[timeZoneMinutes] :: TimeZone -> Int

-- | Is this time zone just persisting for the summer?
[timeZoneSummerOnly] :: TimeZone -> Bool

-- | The name of the zone, typically a three- or four-letter acronym.
[timeZoneName] :: TimeZone -> String

-- | Create a nameless non-summer timezone for this number of minutes.
minutesToTimeZone :: Int -> TimeZone

-- | Create a nameless non-summer timezone for this number of hours.
hoursToTimeZone :: Int -> TimeZone

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like <tt>%z</tt> in formatTime), with arbitrary padding.
timeZoneOffsetString' :: Maybe Char -> TimeZone -> String

-- | Text representing the offset of this timezone, such as "-0800" or
--   "+0400" (like <tt>%z</tt> in formatTime).
timeZoneOffsetString :: TimeZone -> String

-- | The UTC time zone.
utc :: TimeZone

-- | Time of day as represented in hour, minute and second (with
--   picoseconds), typically used to express local time of day.
data TimeOfDay
TimeOfDay :: Int -> Int -> Pico -> TimeOfDay

-- | range 0 - 23
[todHour] :: TimeOfDay -> Int

-- | range 0 - 59
[todMin] :: TimeOfDay -> Int

-- | Note that 0 &lt;= <a>todSec</a> &lt; 61, accomodating leap seconds.
--   Any local minute may have a leap second, since leap seconds happen in
--   all zones simultaneously
[todSec] :: TimeOfDay -> Pico

-- | Hour zero
midnight :: TimeOfDay

-- | Hour twelve
midday :: TimeOfDay
makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay

-- | Convert a time of day in UTC to a time of day in some timezone,
--   together with a day adjustment.
utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)

-- | Convert a time of day in some timezone to a time of day in UTC,
--   together with a day adjustment.
localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)

-- | Get the time of day given a time since midnight. Time more than 24h
--   will be converted to leap-seconds.
timeToTimeOfDay :: DiffTime -> TimeOfDay

-- | Get the time since midnight for a given time of day.
timeOfDayToTime :: TimeOfDay -> DiffTime

-- | Get the time of day given the fraction of a day since midnight.
dayFractionToTimeOfDay :: Rational -> TimeOfDay

-- | Get the fraction of a day since midnight given a time of day.
timeOfDayToDayFraction :: TimeOfDay -> Rational

-- | A simple day and time aggregate, where the day is of the specified
--   parameter, and the time is a TimeOfDay. Conversion of this (as local
--   civil time) to UTC depends on the time zone. Conversion of this (as
--   local mean time) to UT1 depends on the longitude.
data LocalTime
LocalTime :: Day -> TimeOfDay -> LocalTime
[localDay] :: LocalTime -> Day
[localTimeOfDay] :: LocalTime -> TimeOfDay

-- | Get the local time of a UTC time in a time zone.
utcToLocalTime :: TimeZone -> UTCTime -> LocalTime

-- | Get the UTC time of a local time in a time zone.
localTimeToUTC :: TimeZone -> LocalTime -> UTCTime

-- | Get the local time of a UT1 time on a particular meridian (in degrees,
--   positive is East).
ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime

-- | Get the UT1 time of a local time on a particular meridian (in degrees,
--   positive is East).
localTimeToUT1 :: Rational -> LocalTime -> UniversalTime
data TimeLocale
TimeLocale :: [(String, String)] -> [(String, String)] -> (String, String) -> String -> String -> String -> String -> [TimeZone] -> TimeLocale

-- | full and abbreviated week days, starting with Sunday
[wDays] :: TimeLocale -> [(String, String)]

-- | full and abbreviated months
[months] :: TimeLocale -> [(String, String)]

-- | AM/PM symbols
[amPm] :: TimeLocale -> (String, String)

-- | formatting strings
[dateTimeFmt] :: TimeLocale -> String

-- | formatting strings
[dateFmt] :: TimeLocale -> String

-- | formatting strings
[timeFmt] :: TimeLocale -> String

-- | formatting strings
[time12Fmt] :: TimeLocale -> String

-- | time zones known by name
[knownTimeZones] :: TimeLocale -> [TimeZone]

-- | Locale representing American usage.
--   
--   <a>knownTimeZones</a> contains only the ten time-zones mentioned in
--   RFC 822 sec. 5: "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT",
--   "PST", "PDT". Note that the parsing functions will regardless parse
--   single-letter military time-zones and +HHMM format.
defaultTimeLocale :: TimeLocale

-- | Construct format string according to <a>ISO-8601</a>.
--   
--   The <tt>Maybe String</tt> argument allows to supply an optional time
--   specification. E.g.:
--   
--   <pre>
--   <a>iso8601DateFormat</a> Nothing            == "%Y-%m-%d"           -- i.e. <tt><i>YYYY-MM-DD</i></tt>
--   <a>iso8601DateFormat</a> (Just "%H:%M:%S")  == "%Y-%m-%dT%H:%M:%S"  -- i.e. <tt><i>YYYY-MM-DD</i>T<i>HH:MM:SS</i></tt>
--   </pre>
iso8601DateFormat :: Maybe String -> String

-- | Format string according to <a>RFC822</a>.
rfc822DateFormat :: String

-- | A local time together with a time zone.
data ZonedTime
ZonedTime :: LocalTime -> TimeZone -> ZonedTime
[zonedTimeToLocalTime] :: ZonedTime -> LocalTime
[zonedTimeZone] :: ZonedTime -> TimeZone
utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime
zonedTimeToUTC :: ZonedTime -> UTCTime

-- | The class of types which can be parsed given a UNIX-style time format
--   string.
class ParseTime t

-- | Builds a time value from a parsed input string. If the input does not
--   include all the information needed to construct a complete value, any
--   missing parts should be taken from 1970-01-01 00:00:00 +0000 (which
--   was a Thursday). In the absence of <tt>%C</tt> or <tt>%Y</tt>, century
--   is 1969 - 2068.
buildTime :: ParseTime t => TimeLocale -> [(Char, String)] -> Maybe t

-- | Parses a time value given a format string. Supports the same %-codes
--   as <tt>formatTime</tt>, including <tt>%-</tt>, <tt>%_</tt> and
--   <tt>%0</tt> modifiers, however padding widths are not supported. Case
--   is not significant in the input string. Some variations in the input
--   are accepted:
--   
--   <ul>
--   <li><i><tt>%z</tt></i> accepts any of <tt>-HHMM</tt> or
--   <tt>-HH:MM</tt>.</li>
--   <li><i><tt>%Z</tt></i> accepts any string of letters, or any of the
--   formats accepted by <tt>%z</tt>.</li>
--   <li><i><tt>%0Y</tt></i> accepts exactly four digits.</li>
--   <li><i><tt>%0G</tt></i> accepts exactly four digits.</li>
--   <li><i><tt>%0C</tt></i> accepts exactly two digits.</li>
--   <li><i><tt>%0f</tt></i> accepts exactly two digits.</li>
--   </ul>
parseTimeM :: (Monad m, ParseTime t) => Bool -> TimeLocale -> String -> String -> m t

-- | Parse a time value given a format string. Fails if the input could not
--   be parsed using the given format. See <a>parseTimeM</a> for details.
parseTimeOrError :: ParseTime t => Bool -> TimeLocale -> String -> String -> t

-- | Parse a time value given a format string. See <a>parseTimeM</a> for
--   details.
readSTime :: ParseTime t => Bool -> TimeLocale -> String -> ReadS t

-- | Parse a time value given a format string. See <a>parseTimeM</a> for
--   details.
readPTime :: ParseTime t => Bool -> TimeLocale -> String -> ReadP t
readTime :: ParseTime t => TimeLocale -> String -> String -> t
readsTime :: ParseTime t => TimeLocale -> String -> ReadS t
class FormatTime t
formatCharacter :: FormatTime t => Char -> Maybe TimeLocale -> Maybe NumericPadOption -> Maybe Int -> t -> String
type NumericPadOption = Maybe Char

-- | Substitute various time-related information for each %-code in the
--   string, as per <a>formatCharacter</a>.
--   
--   The general form is
--   <tt>%&lt;modifier&gt;&lt;width&gt;&lt;specifier&gt;</tt>, where
--   <tt>&lt;modifier&gt;</tt> and <tt>&lt;width&gt;</tt> are optional.
--   
--   <h2><tt>&lt;modifier&gt;</tt></h2>
--   
--   glibc-style modifiers can be used before the specifier (here marked as
--   <tt>z</tt>):
--   
--   <ul>
--   <li><i><tt>%-z</tt></i> no padding</li>
--   <li><i><tt>%_z</tt></i> pad with spaces</li>
--   <li><i><tt>%0z</tt></i> pad with zeros</li>
--   <li><i><tt>%^z</tt></i> convert to upper case</li>
--   <li><i><tt>%#z</tt></i> convert to lower case (consistently, unlike
--   glibc)</li>
--   </ul>
--   
--   <h2><tt>&lt;width&gt;</tt></h2>
--   
--   Width digits can also be used after any modifiers and before the
--   specifier (here marked as <tt>z</tt>), for example:
--   
--   <ul>
--   <li><i><tt>%4z</tt></i> pad to 4 characters (with default padding
--   character)</li>
--   <li><i><tt>%_12z</tt></i> pad with spaces to 12 characters</li>
--   </ul>
--   
--   <h2><tt>&lt;specifier&gt;</tt></h2>
--   
--   For all types (note these three are done by <a>formatTime</a>, not by
--   <a>formatCharacter</a>):
--   
--   <ul>
--   <li><i><tt>%%</tt></i> <tt>%</tt></li>
--   <li><i><tt>%t</tt></i> tab</li>
--   <li><i><tt>%n</tt></i> newline</li>
--   </ul>
--   
--   <h3><a>TimeZone</a></h3>
--   
--   For <a>TimeZone</a> (and <a>ZonedTime</a> and <a>UTCTime</a>):
--   
--   <ul>
--   <li><i><tt>%z</tt></i> timezone offset in the format
--   <tt>-HHMM</tt>.</li>
--   <li><i><tt>%Z</tt></i> timezone name</li>
--   </ul>
--   
--   <h3><a>LocalTime</a></h3>
--   
--   For <a>LocalTime</a> (and <a>ZonedTime</a> and <a>UTCTime</a> and
--   <a>UniversalTime</a>):
--   
--   <ul>
--   <li><i><tt>%c</tt></i> as <a>dateTimeFmt</a> <tt>locale</tt> (e.g.
--   <tt>%a %b %e %H:%M:%S %Z %Y</tt>)</li>
--   </ul>
--   
--   <h3><a>TimeOfDay</a></h3>
--   
--   For <a>TimeOfDay</a> (and <a>LocalTime</a> and <a>ZonedTime</a> and
--   <a>UTCTime</a> and <a>UniversalTime</a>):
--   
--   <ul>
--   <li><i><tt>%R</tt></i> same as <tt>%H:%M</tt></li>
--   <li><i><tt>%T</tt></i> same as <tt>%H:%M:%S</tt></li>
--   <li><i><tt>%X</tt></i> as <a>timeFmt</a> <tt>locale</tt> (e.g.
--   <tt>%H:%M:%S</tt>)</li>
--   <li><i><tt>%r</tt></i> as <a>time12Fmt</a> <tt>locale</tt> (e.g.
--   <tt>%I:%M:%S %p</tt>)</li>
--   <li><i><tt>%P</tt></i> day-half of day from (<a>amPm</a>
--   <tt>locale</tt>), converted to lowercase, <tt>am</tt>,
--   <tt>pm</tt></li>
--   <li><i><tt>%p</tt></i> day-half of day from (<a>amPm</a>
--   <tt>locale</tt>), <tt>AM</tt>, <tt>PM</tt></li>
--   <li><i><tt>%H</tt></i> hour of day (24-hour), 0-padded to two chars,
--   <tt>00</tt> - <tt>23</tt></li>
--   <li><i><tt>%k</tt></i> hour of day (24-hour), space-padded to two
--   chars, <tt> 0</tt> - <tt>23</tt></li>
--   <li><i><tt>%I</tt></i> hour of day-half (12-hour), 0-padded to two
--   chars, <tt>01</tt> - <tt>12</tt></li>
--   <li><i><tt>%l</tt></i> hour of day-half (12-hour), space-padded to two
--   chars, <tt> 1</tt> - <tt>12</tt></li>
--   <li><i><tt>%M</tt></i> minute of hour, 0-padded to two chars,
--   <tt>00</tt> - <tt>59</tt></li>
--   <li><i><tt>%S</tt></i> second of minute (without decimal part),
--   0-padded to two chars, <tt>00</tt> - <tt>60</tt></li>
--   <li><i><tt>%q</tt></i> picosecond of second, 0-padded to twelve chars,
--   <tt>000000000000</tt> - <tt>999999999999</tt>.</li>
--   <li><i><tt>%Q</tt></i> decimal point and fraction of second, up to 12
--   second decimals, without trailing zeros. For a whole number of
--   seconds, <tt>%Q</tt> omits the decimal point unless padding is
--   specified.</li>
--   </ul>
--   
--   <h3><a>UTCTime</a> and <a>ZonedTime</a></h3>
--   
--   For <a>UTCTime</a> and <a>ZonedTime</a>:
--   
--   <ul>
--   <li><i><tt>%s</tt></i> number of whole seconds since the Unix epoch.
--   For times before the Unix epoch, this is a negative number. Note that
--   in <tt>%s.%q</tt> and <tt>%s%Q</tt> the decimals are positive, not
--   negative. For example, 0.9 seconds before the Unix epoch is formatted
--   as <tt>-1.1</tt> with <tt>%s%Q</tt>.</li>
--   </ul>
--   
--   <h3><a>Day</a></h3>
--   
--   For <a>Day</a> (and <a>LocalTime</a> and <a>ZonedTime</a> and
--   <a>UTCTime</a> and <a>UniversalTime</a>):
--   
--   <ul>
--   <li><i><tt>%D</tt></i> same as <tt>%m/%d/%y</tt></li>
--   <li><i><tt>%F</tt></i> same as <tt>%Y-%m-%d</tt></li>
--   <li><i><tt>%x</tt></i> as <a>dateFmt</a> <tt>locale</tt> (e.g.
--   <tt>%m/%d/%y</tt>)</li>
--   <li><i><tt>%Y</tt></i> year, no padding. Note <tt>%0Y</tt> and
--   <tt>%_Y</tt> pad to four chars</li>
--   <li><i><tt>%y</tt></i> year of century, 0-padded to two chars,
--   <tt>00</tt> - <tt>99</tt></li>
--   <li><i><tt>%C</tt></i> century, no padding. Note <tt>%0C</tt> and
--   <tt>%_C</tt> pad to two chars</li>
--   <li><i><tt>%B</tt></i> month name, long form (<a>fst</a> from
--   <a>months</a> <tt>locale</tt>), <tt>January</tt> -
--   <tt>December</tt></li>
--   <li><i><tt>%b</tt>, <tt>%h</tt></i> month name, short form (<a>snd</a>
--   from <a>months</a> <tt>locale</tt>), <tt>Jan</tt> - <tt>Dec</tt></li>
--   <li><i><tt>%m</tt></i> month of year, 0-padded to two chars,
--   <tt>01</tt> - <tt>12</tt></li>
--   <li><i><tt>%d</tt></i> day of month, 0-padded to two chars,
--   <tt>01</tt> - <tt>31</tt></li>
--   <li><i><tt>%e</tt></i> day of month, space-padded to two chars, <tt>
--   1</tt> - <tt>31</tt></li>
--   <li><i><tt>%j</tt></i> day of year, 0-padded to three chars,
--   <tt>001</tt> - <tt>366</tt></li>
--   <li><i><tt>%f</tt></i> century for Week Date format, no padding. Note
--   <tt>%0f</tt> and <tt>%_f</tt> pad to two chars</li>
--   <li><i><tt>%V</tt></i> week of year for Week Date format, 0-padded to
--   two chars, <tt>01</tt> - <tt>53</tt></li>
--   <li><i><tt>%u</tt></i> day of week for Week Date format, <tt>1</tt> -
--   <tt>7</tt></li>
--   <li><i><tt>%a</tt></i> day of week, short form (<a>snd</a> from
--   <a>wDays</a> <tt>locale</tt>), <tt>Sun</tt> - <tt>Sat</tt></li>
--   <li><i><tt>%A</tt></i> day of week, long form (<a>fst</a> from
--   <a>wDays</a> <tt>locale</tt>), <tt>Sunday</tt> -
--   <tt>Saturday</tt></li>
--   <li><i><tt>%U</tt></i> week of year where weeks start on Sunday (as
--   <a>sundayStartWeek</a>), 0-padded to two chars, <tt>00</tt> -
--   <tt>53</tt></li>
--   <li><i><tt>%w</tt></i> day of week number, <tt>0</tt> (= Sunday) -
--   <tt>6</tt> (= Saturday)</li>
--   <li><i><tt>%W</tt></i> week of year where weeks start on Monday (as
--   <a>mondayStartWeek</a>), 0-padded to two chars, <tt>00</tt> -
--   <tt>53</tt></li>
--   </ul>
formatTime :: FormatTime t => TimeLocale -> String -> t -> String

-- | create an additional set of translations for a type created by
--   <a>mkMessage</a>
mkMessageVariant :: String -> String -> FilePath -> Lang -> Q [Dec]

-- | create <a>RenderMessage</a> instance for an existing data-type
mkMessageFor :: String -> String -> FilePath -> Lang -> Q [Dec]

-- | generate translations from translation files
--   
--   This function will:
--   
--   <ol>
--   <li>look in the supplied subdirectory for files ending in
--   <tt>.msg</tt></li>
--   <li>generate a type based on the constructors found</li>
--   <li>create a <a>RenderMessage</a> instance</li>
--   </ol>
mkMessage :: String -> FilePath -> Lang -> Q [Dec]

-- | <a>ToMessage</a> is used to convert the value inside #{ } to
--   <a>Text</a>
--   
--   The primary purpose of this class is to allow the value in #{ } to be
--   a <a>String</a> or <a>Text</a> rather than forcing it to always be
--   <a>Text</a>.
class ToMessage a
toMessage :: ToMessage a => a -> Text

-- | the <a>RenderMessage</a> is used to provide translations for a message
--   types
--   
--   The <tt>master</tt> argument exists so that it is possible to provide
--   more than one set of translations for a <tt>message</tt> type. This is
--   useful if a library provides a default set of translations, but the
--   user of the library wants to provide a different set of translations.
class RenderMessage master message
renderMessage :: RenderMessage master message => master -> [Lang] -> message -> Text

-- | an RFC1766 / ISO 639-1 language code (eg, <tt>fr</tt>, <tt>en-GB</tt>,
--   etc).
type Lang = Text
data SomeMessage master
[SomeMessage] :: SomeMessage master
cassius :: QuasiQuoter

-- | Like <a>hamlet</a>, but produces XHTML.
xhamlet :: QuasiQuoter

-- | Hamlet quasi-quoter. May only be used to generate expressions.
--   
--   Generated expression have type <tt><a>HtmlUrl</a> url</tt>, for some
--   <tt>url</tt>.
--   
--   <pre>
--   data MyRoute = Home
--   
--   render :: <a>Render</a> MyRoute
--   render Home _ = "/home"
--   
--   &gt;&gt;&gt; <a>putStrLn</a> (<a>renderHtml</a> ([<a>hamlet</a>|&lt;a href=@{Home}&gt;Home|] render))
--   &lt;a href="/home"&gt;Home&lt;/a&gt;
--   </pre>
hamlet :: QuasiQuoter

-- | "Simple Hamlet" quasi-quoter. May only be used to generate
--   expressions.
--   
--   Generated expressions have type <a>Html</a>.
--   
--   <pre>
--   &gt;&gt;&gt; <a>putStrLn</a> (<a>renderHtml</a> [<a>shamlet</a>|&lt;div&gt;Hello, world!|])
--   &lt;div&gt;Hello, world!&lt;/div&gt;
--   </pre>
shamlet :: QuasiQuoter

-- | A function generating an <a>Html</a> given a URL-rendering function.
type HtmlUrl url = Render url -> Html

-- | <pre>
--   &gt;&gt;&gt; renderCss ([lucius|foo{bar:baz}|] undefined)
--   "foo{bar:baz}"
--   </pre>
lucius :: QuasiQuoter
renderCssUrl :: () => url -> [(Text, Text)] -> Text -> CssUrl url -> Text
type CssUrl url = url -> [(Text, Text)] -> Text -> Css
julius :: QuasiQuoter

-- | render with route interpolation. If using this module standalone,
--   apart from type-safe routes, a dummy renderer can be used:
--   
--   <pre>
--   renderJavascriptUrl (\_ _ -&gt; undefined) javascriptUrl
--   </pre>
--   
--   When using Yesod, a renderer is generated for you, which can be
--   accessed within the GHandler monad: <a>getUrlRenderParams</a>.
renderJavascriptUrl :: () => url -> [(Text, Text)] -> Text -> JavascriptUrl url -> Text

-- | Return type of template-reading functions.
type JavascriptUrl url = url -> [(Text, Text)] -> Text -> Javascript

utcToLocalZonedTime :: UTCTime -> IO ZonedTime
getZonedTime :: IO ZonedTime

-- | Get the current time-zone.
getCurrentTimeZone :: IO TimeZone

-- | Get the local time-zone for a given time (varying as per summertime
--   adjustments).
getTimeZone :: UTCTime -> IO TimeZone

-- | Get the current <a>UTCTime</a> from the system clock.
getCurrentTime :: IO UTCTime

-- | The WAI application.
--   
--   Note that, since WAI 3.0, this type is structured in continuation
--   passing style to allow for proper safe resource handling. This was
--   handled in the past via other means (e.g., <tt>ResourceT</tt>). As a
--   demonstration:
--   
--   <pre>
--   app :: Application
--   app req respond = bracket_
--       (putStrLn "Allocating scarce resource")
--       (putStrLn "Cleaning up")
--       (respond $ responseLBS status200 [] "Hello World")
--   </pre>
type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived
newtype DBRunner site
DBRunner :: forall a. () => YesodDB site a -> HandlerFor site a -> DBRunner site
[runDBRunner] :: DBRunner site -> forall a. () => YesodDB site a -> HandlerFor site a

-- | Since 1.2.0
class YesodPersist site => YesodPersistRunner site

-- | This function differs from <a>runDB</a> in that it returns a database
--   runner function, as opposed to simply running a single action. This
--   will usually mean that a connection is taken from a pool and then
--   reused for each invocation. This can be useful for creating streaming
--   responses; see <a>runDBSource</a>.
--   
--   It additionally returns a cleanup function to free the connection. If
--   your code finishes successfully, you <i>must</i> call this cleanup to
--   indicate changes should be committed. Otherwise, for SQL backends at
--   least, a rollback will be used instead.
--   
--   Since 1.2.0
getDBRunner :: YesodPersistRunner site => HandlerFor site (DBRunner site, HandlerFor site ())
class Monad YesodDB site => YesodPersist site where {
    type family YesodPersistBackend site :: *;
}
runDB :: YesodPersist site => YesodDB site a -> HandlerFor site a
type YesodDB site = ReaderT YesodPersistBackend site HandlerFor site

-- | Helper for creating <a>runDB</a>.
--   
--   Since 1.2.0
defaultRunDB :: PersistConfig c => site -> c -> site -> PersistConfigPool c -> PersistConfigBackend c HandlerFor site a -> HandlerFor site a

-- | Helper for implementing <a>getDBRunner</a>.
--   
--   Since 1.2.0
defaultGetDBRunner :: (IsSqlBackend backend, YesodPersistBackend site ~ backend) => site -> Pool backend -> HandlerFor site (DBRunner site, HandlerFor site ())

-- | Like <a>runDB</a>, but transforms a <tt>Source</tt>. See
--   <a>respondSourceDB</a> for an example, practical use case.
--   
--   Since 1.2.0
runDBSource :: YesodPersistRunner site => ConduitT () a YesodDB site () -> ConduitT () a HandlerFor site ()

-- | Extends <a>respondSource</a> to create a streaming database response
--   body.
respondSourceDB :: YesodPersistRunner site => ContentType -> ConduitT () Flush Builder YesodDB site () -> HandlerFor site TypedContent

-- | Get the given entity by ID, or return a 404 not found if it doesn't
--   exist.
get404 :: (MonadIO m, PersistStoreRead backend, PersistRecordBackend val backend) => Key val -> ReaderT backend m val

-- | Get the given entity by unique key, or return a 404 not found if it
--   doesn't exist.
getBy404 :: (PersistUniqueRead backend, PersistRecordBackend val backend, MonadIO m) => Unique val -> ReaderT backend m Entity val

-- | Create a new record in the database, returning an automatically
--   created key, or raise a 400 bad request if a uniqueness constraint is
--   violated.
insert400 :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend) => val -> ReaderT backend m Key val

-- | Same as <a>insert400</a>, but doesn’t return a key.
insert400_ :: (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend val backend) => val -> ReaderT backend m ()
data FormMessage
MsgInvalidInteger :: Text -> FormMessage
MsgInvalidNumber :: Text -> FormMessage
MsgInvalidEntry :: Text -> FormMessage
MsgInvalidUrl :: Text -> FormMessage
MsgInvalidEmail :: Text -> FormMessage
MsgInvalidTimeFormat :: FormMessage
MsgInvalidHour :: Text -> FormMessage
MsgInvalidMinute :: Text -> FormMessage
MsgInvalidSecond :: Text -> FormMessage
MsgInvalidDay :: FormMessage
MsgCsrfWarning :: FormMessage
MsgValueRequired :: FormMessage
MsgInputNotFound :: Text -> FormMessage
MsgSelectNone :: FormMessage
MsgInvalidBool :: Text -> FormMessage
MsgBoolYes :: FormMessage
MsgBoolNo :: FormMessage
MsgDelete :: FormMessage
data Field (m :: * -> *) a
Field :: [Text] -> [FileInfo] -> m Either SomeMessage HandlerSite m Maybe a -> FieldViewFunc m a -> Enctype -> Field a
[fieldParse] :: Field a -> [Text] -> [FileInfo] -> m Either SomeMessage HandlerSite m Maybe a
[fieldView] :: Field a -> FieldViewFunc m a
[fieldEnctype] :: Field a -> Enctype
type FieldViewFunc (m :: * -> *) a = Text -> Text -> [(Text, Text)] -> Either Text a -> Bool -> WidgetFor HandlerSite m ()
data FieldView site
FieldView :: Markup -> Maybe Markup -> Text -> WidgetFor site () -> Maybe Markup -> Bool -> FieldView site
[fvLabel] :: FieldView site -> Markup
[fvTooltip] :: FieldView site -> Maybe Markup
[fvId] :: FieldView site -> Text
[fvInput] :: FieldView site -> WidgetFor site ()
[fvErrors] :: FieldView site -> Maybe Markup
[fvRequired] :: FieldView site -> Bool
data FieldSettings master
FieldSettings :: SomeMessage master -> Maybe SomeMessage master -> Maybe Text -> Maybe Text -> [(Text, Text)] -> FieldSettings master
[fsLabel] :: FieldSettings master -> SomeMessage master
[fsTooltip] :: FieldSettings master -> Maybe SomeMessage master
[fsId] :: FieldSettings master -> Maybe Text
[fsName] :: FieldSettings master -> Maybe Text
[fsAttrs] :: FieldSettings master -> [(Text, Text)]
newtype AForm (m :: * -> *) a
AForm :: (HandlerSite m, [Text]) -> Maybe (Env, FileEnv) -> Ints -> m (FormResult a, [FieldView HandlerSite m] -> [FieldView HandlerSite m], Ints, Enctype) -> AForm a
[unAForm] :: AForm a -> (HandlerSite m, [Text]) -> Maybe (Env, FileEnv) -> Ints -> m (FormResult a, [FieldView HandlerSite m] -> [FieldView HandlerSite m], Ints, Enctype)
type MForm (m :: * -> *) a = RWST (Maybe (Env, FileEnv), HandlerSite m, [Lang]) Enctype Ints m a

-- | <a>MForm</a> variant stacking a <a>WriterT</a>. The following code
--   example using a monadic form <a>MForm</a>:
--   
--   <pre>
--   formToAForm $ do
--     (field1F, field1V) &lt;- mreq textField MsgField1 Nothing
--     (field2F, field2V) &lt;- mreq (checkWith field1F textField) MsgField2 Nothing
--     (field3F, field3V) &lt;- mreq (checkWith field1F textField) MsgField3 Nothing
--     return
--       ( MyForm &lt;$&gt; field1F &lt;*&gt; field2F &lt;*&gt; field3F
--       , [field1V, field2V, field3V]
--       )
--   </pre>
--   
--   Could be rewritten as follows using <a>WForm</a>:
--   
--   <pre>
--   wFormToAForm $ do
--     field1F &lt;- wreq textField MsgField1 Nothing
--     field2F &lt;- wreq (checkWith field1F textField) MsgField2 Nothing
--     field3F &lt;- wreq (checkWith field1F textField) MsgField3 Nothing
--     return $ MyForm &lt;$&gt; field1F &lt;*&gt; field2F &lt;*&gt; field3F
--   </pre>
type WForm (m :: * -> *) a = MForm WriterT [FieldView HandlerSite m] m a
type FileEnv = Map Text [FileInfo]
type Env = Map Text [Text]
data Ints
IntCons :: Int -> Ints -> Ints
IntSingle :: Int -> Ints

-- | The encoding type required by a form. The <tt>ToHtml</tt> instance
--   produces values that can be inserted directly into HTML.
data Enctype
UrlEncoded :: Enctype
Multipart :: Enctype

-- | A form can produce three different results: there was no data
--   available, the data was invalid, or there was a successful parse.
--   
--   The <a>Applicative</a> instance will concatenate the failure messages
--   in two <a>FormResult</a>s. The <a>Alternative</a> instance will choose
--   <a>FormFailure</a> before <a>FormSuccess</a>, and <a>FormMissing</a>
--   last of all.
data FormResult a
FormMissing :: FormResult a
FormFailure :: [Text] -> FormResult a
FormSuccess :: a -> FormResult a

-- | Type for a form which parses a value of type <tt>a</tt> with the base
--   monad <tt>m</tt> (usually your <tt>Handler</tt>). Can compose this
--   using its <tt>Applicative</tt> instance.
newtype FormInput (m :: * -> *) a
FormInput :: HandlerSite m -> [Text] -> Env -> FileEnv -> m Either DText a -> FormInput a
[unFormInput] :: FormInput a -> HandlerSite m -> [Text] -> Env -> FileEnv -> m Either DText a

-- | Promote a <tt>Field</tt> into a <tt>FormInput</tt>, requiring that the
--   value be present and valid.
ireq :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m a -> Text -> FormInput m a

-- | Promote a <tt>Field</tt> into a <tt>FormInput</tt>, with its presence
--   being optional. If the value is present but does not parse correctly,
--   the form will still fail.
iopt :: Monad m => Field m a -> Text -> FormInput m Maybe a

-- | Run a <tt>FormInput</tt> on the GET parameters (i.e., query string).
--   If parsing fails, calls <a>invalidArgs</a>.
runInputGet :: MonadHandler m => FormInput m a -> m a

-- | Run a <tt>FormInput</tt> on the GET parameters (i.e., query string).
--   Does <i>not</i> throw exceptions on failure.
--   
--   Since 1.4.1
runInputGetResult :: MonadHandler m => FormInput m a -> m FormResult a

-- | Run a <tt>FormInput</tt> on the POST parameters (i.e., request body).
--   If parsing fails, calls <a>invalidArgs</a>.
runInputPost :: MonadHandler m => FormInput m a -> m a

-- | Run a <tt>FormInput</tt> on the POST parameters (i.e., request body).
--   Does <i>not</i> throw exceptions on failure.
runInputPostResult :: MonadHandler m => FormInput m a -> m FormResult a
type FormRender (m :: * -> *) a = AForm m a -> Markup -> MForm m (FormResult a, WidgetFor HandlerSite m ())

-- | Get a unique identifier.
newFormIdent :: Monad m => MForm m Text
formToAForm :: (HandlerSite m ~ site, Monad m) => MForm m (FormResult a, [FieldView site]) -> AForm m a
aFormToForm :: (Monad m, HandlerSite m ~ site) => AForm m a -> MForm m (FormResult a, [FieldView site] -> [FieldView site])
askParams :: Monad m => MForm m Maybe Env
askFiles :: Monad m => MForm m Maybe FileEnv

-- | Converts a form field into monadic form <a>WForm</a>. This field
--   requires a value and will return <a>FormFailure</a> if left empty.
wreq :: (RenderMessage site FormMessage, HandlerSite m ~ site, MonadHandler m) => Field m a -> FieldSettings site -> Maybe a -> WForm m FormResult a

-- | Converts a form field into monadic form <a>WForm</a>. This field is
--   optional, i.e. if filled in, it returns 'Just a', if left empty, it
--   returns <a>Nothing</a>. Arguments are the same as for <a>wreq</a>
--   (apart from type of default value).
wopt :: (MonadHandler m, HandlerSite m ~ site) => Field m a -> FieldSettings site -> Maybe Maybe a -> WForm m FormResult Maybe a

-- | Converts a monadic form <a>WForm</a> into an applicative form
--   <a>AForm</a>.
wFormToAForm :: MonadHandler m => WForm m FormResult a -> AForm m a

-- | Converts a monadic form <a>WForm</a> into another monadic form
--   <a>MForm</a>.
wFormToMForm :: (MonadHandler m, HandlerSite m ~ site) => WForm m a -> MForm m (a, [FieldView site])

-- | Converts a monadic form <a>MForm</a> into another monadic form
--   <a>WForm</a>.
mFormToWForm :: (MonadHandler m, HandlerSite m ~ site) => MForm m (a, FieldView site) -> WForm m a

-- | Converts a form field into monadic form. This field requires a value
--   and will return <a>FormFailure</a> if left empty.
mreq :: (RenderMessage site FormMessage, HandlerSite m ~ site, MonadHandler m) => Field m a -> FieldSettings site -> Maybe a -> MForm m (FormResult a, FieldView site)

-- | Converts a form field into monadic form. This field is optional, i.e.
--   if filled in, it returns 'Just a', if left empty, it returns
--   <a>Nothing</a>. Arguments are the same as for <a>mreq</a> (apart from
--   type of default value).
mopt :: (site ~ HandlerSite m, MonadHandler m) => Field m a -> FieldSettings site -> Maybe Maybe a -> MForm m (FormResult Maybe a, FieldView site)

-- | Applicative equivalent of <a>mreq</a>.
areq :: (RenderMessage site FormMessage, HandlerSite m ~ site, MonadHandler m) => Field m a -> FieldSettings site -> Maybe a -> AForm m a

-- | Applicative equivalent of <a>mopt</a>.
aopt :: MonadHandler m => Field m a -> FieldSettings HandlerSite m -> Maybe Maybe a -> AForm m Maybe a

-- | This function is used to both initially render a form and to later
--   extract results from it. Note that, due to CSRF protection and a few
--   other issues, forms submitted via GET and POST are slightly different.
--   As such, be sure to call the relevant function based on how the form
--   will be submitted, <i>not</i> the current request method.
--   
--   For example, a common case is displaying a form on a GET request and
--   having the form submit to a POST page. In such a case, both the GET
--   and POST handlers should use <a>runFormPost</a>.
runFormPost :: (RenderMessage HandlerSite m FormMessage, MonadResource m, MonadHandler m) => Markup -> MForm m (FormResult a, xml) -> m ((FormResult a, xml), Enctype)

-- | Similar to <a>runFormPost</a>, except it always ignores the currently
--   available environment. This is necessary in cases like a wizard UI,
--   where a single page will both receive and incoming form and produce a
--   new, blank form. For general usage, you can stick with
--   <tt>runFormPost</tt>.
generateFormPost :: (RenderMessage HandlerSite m FormMessage, MonadHandler m) => Markup -> MForm m (FormResult a, xml) -> m (xml, Enctype)
runFormPostNoToken :: MonadHandler m => Markup -> MForm m a -> m (a, Enctype)
runFormGet :: MonadHandler m => Markup -> MForm m a -> m (a, Enctype)

-- | Since 1.3.11
generateFormGet' :: MonadHandler m => Markup -> MForm m (FormResult a, xml) -> m (xml, Enctype)
generateFormGet :: MonadHandler m => Markup -> MForm m a -> m (a, Enctype)

-- | Creates a hidden field on the form that identifies it. This
--   identification is then used to distinguish between <i>missing</i> and
--   <i>wrong</i> form data when a single handler contains more than one
--   form.
--   
--   For instance, if you have the following code on your handler:
--   
--   <pre>
--   ((fooRes, fooWidget), fooEnctype) &lt;- runFormPost fooForm
--   ((barRes, barWidget), barEnctype) &lt;- runFormPost barForm
--   </pre>
--   
--   Then replace it with
--   
--   <pre>
--   ((fooRes, fooWidget), fooEnctype) &lt;- runFormPost $ identifyForm "foo" fooForm
--   ((barRes, barWidget), barEnctype) &lt;- runFormPost $ identifyForm "bar" barForm
--   </pre>
--   
--   Note that it's your responsibility to ensure that the identification
--   strings are unique (using the same one twice on a single handler will
--   not generate any errors). This allows you to create a variable number
--   of forms and still have them work even if their number or order change
--   between the HTML generation and the form submission.
identifyForm :: Monad m => Text -> Markup -> MForm m (FormResult a, WidgetFor HandlerSite m ()) -> Markup -> MForm m (FormResult a, WidgetFor HandlerSite m ())

-- | Render a form into a series of tr tags. Note that, in order to allow
--   you to add extra rows to the table, this function does <i>not</i> wrap
--   up the resulting HTML in a table tag; you must do that yourself.
renderTable :: Monad m => FormRender m a

-- | render a field inside a div
renderDivs :: Monad m => FormRender m a

-- | render a field inside a div, not displaying any label
renderDivsNoLabels :: Monad m => FormRender m a

-- | Render a form using Bootstrap v2-friendly shamlet syntax. If you're
--   using Bootstrap v3, then you should use the functions from module
--   <a>Yesod.Form.Bootstrap3</a>.
--   
--   Sample Hamlet:
--   
--   <pre>
--   &lt;form .form-horizontal method=post action=@{ActionR} enctype=#{formEnctype}&gt;
--     &lt;fieldset&gt;
--       &lt;legend&gt;_{MsgLegend}
--       $case result
--         $of FormFailure reasons
--           $forall reason &lt;- reasons
--             &lt;div .alert .alert-error&gt;#{reason}
--         $of _
--       ^{formWidget}
--       &lt;div .form-actions&gt;
--         &lt;input .btn .primary type=submit value=_{MsgSubmit}&gt;
--   </pre>
--   
--   Since 1.3.14
renderBootstrap2 :: Monad m => FormRender m a

-- | Deprecated synonym for <a>renderBootstrap2</a>.
renderBootstrap :: Monad m => FormRender m a
check :: (Monad m, RenderMessage HandlerSite m msg) => a -> Either msg a -> Field m a -> Field m a

-- | Return the given error message if the predicate is false.
checkBool :: (Monad m, RenderMessage HandlerSite m msg) => a -> Bool -> msg -> Field m a -> Field m a
checkM :: (Monad m, RenderMessage HandlerSite m msg) => a -> m Either msg a -> Field m a -> Field m a

-- | Same as <a>checkM</a>, but modifies the datatype.
--   
--   In order to make this work, you must provide a function to convert
--   back from the new datatype to the old one (the second argument to this
--   function).
--   
--   Since 1.1.2
checkMMap :: (Monad m, RenderMessage HandlerSite m msg) => a -> m Either msg b -> b -> a -> Field m a -> Field m b

-- | Allows you to overwrite the error message on parse error.
customErrorMessage :: Monad m => SomeMessage HandlerSite m -> Field m a -> Field m a

-- | Generate a <a>FieldSettings</a> from the given label.
fieldSettingsLabel :: RenderMessage site msg => msg -> FieldSettings site

-- | A helper function for creating custom fields.
--   
--   This is intended to help with the common case where a single input
--   value is required, such as when parsing a text field.
--   
--   Since 1.1
parseHelper :: (Monad m, RenderMessage site FormMessage) => Text -> Either FormMessage a -> [Text] -> [FileInfo] -> m Either SomeMessage site Maybe a

-- | A generalized version of <a>parseHelper</a>, allowing any type for the
--   message indicating a bad parse.
--   
--   Since 1.3.6
parseHelperGen :: (Monad m, RenderMessage site msg) => Text -> Either msg a -> [Text] -> [FileInfo] -> m Either SomeMessage site Maybe a

-- | Since a <a>Field</a> cannot be a <a>Functor</a>, it is not obvious how
--   to "reuse" a Field on a <tt>newtype</tt> or otherwise equivalent type.
--   This function allows you to convert a <tt>Field m a</tt> to a
--   <tt>Field m b</tt> assuming you provide a bidirectional conversion
--   between the two, through the first two functions.
--   
--   A simple example:
--   
--   <pre>
--   import Data.Monoid
--   sumField :: (Functor m, Monad m, RenderMessage (HandlerSite m) FormMessage) =&gt; Field m (Sum Int)
--   sumField = convertField Sum getSum intField
--   </pre>
--   
--   Another example, not using a newtype, but instead creating a Lazy Text
--   field:
--   
--   <pre>
--   import qualified Data.Text.Lazy as TL
--   TextField :: (Functor m, Monad m, RenderMessage (HandlerSite m) FormMessage) =&gt; Field m TL.Text
--   lazyTextField = convertField TL.fromStrict TL.toStrict textField
--   </pre>
--   
--   Since 1.3.16
convertField :: Functor m => a -> b -> b -> a -> Field m a -> Field m b

-- | Removes a CSS class from the <a>fsAttrs</a> in a <a>FieldSettings</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; removeClass "form-control" [("class","form-control login-form"),("id","home-login")]
--   [("class","  login-form"),("id","home-login")]
--   </pre>
removeClass :: Text -> [(Text, Text)] -> [(Text, Text)]

-- | Adds a CSS class to the <a>fsAttrs</a> in a <a>FieldSettings</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   <pre>
--   &gt;&gt;&gt; addClass "login-form" [("class", "form-control"), ("id", "home-login")]
--   [("class","form-control login-form"),("id","home-login")]
--   </pre>
addClass :: Text -> [(Text, Text)] -> [(Text, Text)]
data Option a
Option :: Text -> a -> Text -> Option a

-- | The user-facing label.
[optionDisplay] :: Option a -> Text

-- | The Haskell value being selected.
[optionInternalValue] :: Option a -> a

-- | The representation of this value stored in the form.
[optionExternalValue] :: Option a -> Text

-- | A structure holding a list of options. Typically you can use a
--   convenience function like <a>mkOptionList</a> or <a>optionsPairs</a>
--   instead of creating this directly.
data OptionList a
OptionList :: [Option a] -> Text -> Maybe a -> OptionList a
[olOptions] :: OptionList a -> [Option a]

-- | A function mapping from the form's value (<a>optionExternalValue</a>)
--   to the selected Haskell value (<a>optionInternalValue</a>).
[olReadExternal] :: OptionList a -> Text -> Maybe a
type AutoFocus = Bool

-- | A newtype wrapper around a <a>Text</a> whose <a>ToMarkup</a> instance
--   converts newlines to HTML <tt>&lt;br&gt;</tt> tags.
--   
--   (When text is entered into a <tt>&lt;textarea&gt;</tt>, newline
--   characters are used to separate lines. If this text is then placed
--   verbatim into HTML, the lines won't be separated, thus the need for
--   replacing with <tt>&lt;br&gt;</tt> tags). If you don't need this
--   functionality, simply use <a>unTextarea</a> to access the raw text.
newtype Textarea
Textarea :: Text -> Textarea
[unTextarea] :: Textarea -> Text
defaultFormMessage :: FormMessage -> Text

-- | Creates a input with <tt>type="number"</tt> and <tt>step=1</tt>.
intField :: (Monad m, Integral i, RenderMessage HandlerSite m FormMessage) => Field m i

-- | Creates a input with <tt>type="number"</tt> and <tt>step=any</tt>.
doubleField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Double

-- | Creates an input with <tt>type="date"</tt>, validating the input using
--   the <a>parseDate</a> function.
--   
--   Add the <tt>time</tt> package and import the <a>Data.Time.Calendar</a>
--   module to use this function.
dayField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Day

-- | An alias for <a>timeFieldTypeTime</a>.
timeField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m TimeOfDay

-- | Creates an input with <tt>type="time"</tt>. <a>Browsers not supporting
--   this type</a> will fallback to a text field, and Yesod will parse the
--   time as described in <a>timeFieldTypeText</a>.
--   
--   Add the <tt>time</tt> package and import the
--   <a>Data.Time.LocalTime</a> module to use this function.
--   
--   Since 1.4.2
timeFieldTypeTime :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m TimeOfDay

-- | Creates an input with <tt>type="text"</tt>, parsing the time from an
--   [H]H:MM[:SS] format, with an optional AM or PM (if not given, AM is
--   assumed for compatibility with the 24 hour clock system).
--   
--   This function exists for backwards compatibility with the old
--   implementation of <a>timeField</a>, which used to use
--   <tt>type="text"</tt>. Consider using <a>timeField</a> or
--   <a>timeFieldTypeTime</a> for improved UX and validation from the
--   browser.
--   
--   Add the <tt>time</tt> package and import the
--   <a>Data.Time.LocalTime</a> module to use this function.
--   
--   Since 1.4.2
timeFieldTypeText :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m TimeOfDay

-- | Creates a <tt>&lt;textarea&gt;</tt> tag whose input is sanitized to
--   prevent XSS attacks and is validated for having balanced tags.
htmlField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Html

-- | Creates a <tt>&lt;textarea&gt;</tt> tag whose returned value is
--   wrapped in a <a>Textarea</a>; see <a>Textarea</a> for details.
textareaField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Textarea

-- | Creates an input with <tt>type="hidden"</tt>; you can use this to
--   store information in a form that users shouldn't see (for example,
--   Yesod stores CSRF tokens in a hidden field).
hiddenField :: (Monad m, PathPiece p, RenderMessage HandlerSite m FormMessage) => Field m p

-- | Creates a input with <tt>type="text"</tt>.
textField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Text

-- | Creates an input with <tt>type="password"</tt>.
passwordField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Text

-- | Parses a <a>Day</a> from a <a>String</a>.
parseDate :: String -> Either FormMessage Day
parseTime :: Text -> Either FormMessage TimeOfDay

-- | Creates an input with <tt>type="email"</tt>. Yesod will validate the
--   email's correctness according to RFC5322 and canonicalize it by
--   removing comments and whitespace (see <a>Text.Email.Validate</a>).
emailField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Text

-- | Creates an input with <tt>type="email"</tt> with the <a>multiple</a>
--   attribute; browsers might implement this as taking a comma separated
--   list of emails. Each email address is validated as described in
--   <a>emailField</a>.
--   
--   Since 1.3.7
multiEmailField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m [Text]

-- | Creates an input with <tt>type="search"</tt>. For <a>browsers without
--   autofocus support</a>, a JS fallback is used if <tt>AutoFocus</tt> is
--   true.
searchField :: (Monad m, RenderMessage HandlerSite m FormMessage) => AutoFocus -> Field m Text

-- | Creates an input with <tt>type="url"</tt>, validating the URL
--   according to RFC3986.
urlField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Text

-- | Creates a <tt>&lt;select&gt;</tt> tag for selecting one option.
--   Example usage:
--   
--   <pre>
--   areq (selectFieldList [("Value 1" :: Text, "value1"),("Value 2", "value2")]) "Which value?" Nothing
--   </pre>
selectFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field HandlerFor site a

-- | Creates a <tt>&lt;select&gt;</tt> tag for selecting one option.
--   Example usage:
--   
--   <pre>
--   areq (selectField $ optionsPairs [(MsgValue1, "value1"),(MsgValue2, "value2")]) "Which value?" Nothing
--   </pre>
selectField :: (Eq a, RenderMessage site FormMessage) => HandlerFor site OptionList a -> Field HandlerFor site a

-- | Creates a <tt>&lt;select&gt;</tt> tag for selecting multiple options.
multiSelectFieldList :: (Eq a, RenderMessage site msg) => [(msg, a)] -> Field HandlerFor site [a]

-- | Creates a <tt>&lt;select&gt;</tt> tag for selecting multiple options.
multiSelectField :: Eq a => HandlerFor site OptionList a -> Field HandlerFor site [a]

-- | Creates an input with <tt>type="radio"</tt> for selecting one option.
radioFieldList :: (Eq a, RenderMessage site FormMessage, RenderMessage site msg) => [(msg, a)] -> Field HandlerFor site a

-- | Creates an input with <tt>type="checkbox"</tt> for selecting multiple
--   options.
checkboxesFieldList :: (Eq a, RenderMessage site msg) => [(msg, a)] -> Field HandlerFor site [a]

-- | Creates an input with <tt>type="checkbox"</tt> for selecting multiple
--   options.
checkboxesField :: Eq a => HandlerFor site OptionList a -> Field HandlerFor site [a]

-- | Creates an input with <tt>type="radio"</tt> for selecting one option.
radioField :: (Eq a, RenderMessage site FormMessage) => HandlerFor site OptionList a -> Field HandlerFor site a

-- | Creates a group of radio buttons to answer the question given in the
--   message. Radio buttons are used to allow differentiating between an
--   empty response (<tt>Nothing</tt>) and a no response (<tt>Just
--   False</tt>). Consider using the simpler <a>checkBoxField</a> if you
--   don't need to make this distinction.
--   
--   If this field is optional, the first radio button is labeled
--   "&lt;None&gt;", the second "Yes" and the third "No".
--   
--   If this field is required, the first radio button is labeled "Yes" and
--   the second "No".
--   
--   (Exact label titles will depend on localization).
boolField :: (Monad m, RenderMessage HandlerSite m FormMessage) => Field m Bool

-- | Creates an input with <tt>type="checkbox"</tt>. While the default
--   <tt><a>boolField</a></tt> implements a radio button so you can
--   differentiate between an empty response (<tt>Nothing</tt>) and a no
--   response (<tt>Just False</tt>), this simpler checkbox field returns an
--   empty response as <tt>Just False</tt>.
--   
--   Note that this makes the field always optional.
checkBoxField :: Monad m => Field m Bool

-- | Creates an <a>OptionList</a>, using a <tt>Map</tt> to implement the
--   <a>olReadExternal</a> function.
mkOptionList :: () => [Option a] -> OptionList a

-- | Creates an <a>OptionList</a> from a list of (display-value, internal
--   value) pairs.
optionsPairs :: (MonadHandler m, RenderMessage HandlerSite m msg) => [(msg, a)] -> m OptionList a

-- | Creates an <a>OptionList</a> from an <a>Enum</a>, using its
--   <a>Show</a> instance for the user-facing value.
optionsEnum :: (MonadHandler m, Show a, Enum a, Bounded a) => m OptionList a

-- | Selects a list of <a>Entity</a>s with the given <a>Filter</a> and
--   <a>SelectOpt</a>s. The <tt>(a -&gt; msg)</tt> function is then used to
--   derive the display value for an <a>OptionList</a>. Example usage:
--   
--   <pre>
--   Country
--      name Text
--      deriving Eq -- Must derive Eq
--   </pre>
--   
--   <pre>
--   data CountryForm = CountryForm
--     { country :: Entity Country
--     }
--   
--   countryNameForm :: AForm Handler CountryForm
--   countryNameForm = CountryForm
--           &lt;$&gt; areq (selectField countries) "Which country do you live in?" Nothing
--           where
--             countries = optionsPersist [] [Asc CountryName] countryName
--   </pre>
optionsPersist :: (YesodPersist site, PersistQueryRead backend, PathPiece Key a, RenderMessage site msg, YesodPersistBackend site ~ backend, PersistRecordBackend a backend) => [Filter a] -> [SelectOpt a] -> a -> msg -> HandlerFor site OptionList Entity a

-- | An alternative to <a>optionsPersist</a> which returns just the
--   <a>Key</a> instead of the entire <a>Entity</a>.
--   
--   Since 1.3.2
optionsPersistKey :: (YesodPersist site, PersistQueryRead backend, PathPiece Key a, RenderMessage site msg, backend ~ YesodPersistBackend site, PersistRecordBackend a backend) => [Filter a] -> [SelectOpt a] -> a -> msg -> HandlerFor site OptionList Key a

-- | A helper function for constucting <a>selectField</a>s. You may want to
--   use this when you define your custom <a>selectField</a>s or
--   <a>radioField</a>s.
selectFieldHelper :: (Eq a, RenderMessage site FormMessage) => Text -> Text -> [(Text, Text)] -> WidgetFor site () -> WidgetFor site () -> Text -> Text -> Bool -> WidgetFor site () -> Text -> Text -> [(Text, Text)] -> Text -> Bool -> Text -> WidgetFor site () -> HandlerFor site OptionList a -> Field HandlerFor site a

-- | Creates an input with <tt>type="file"</tt>.
fileField :: Monad m => Field m FileInfo
fileAFormReq :: (MonadHandler m, RenderMessage HandlerSite m FormMessage) => FieldSettings HandlerSite m -> AForm m FileInfo
fileAFormOpt :: MonadHandler m => FieldSettings HandlerSite m -> AForm m Maybe FileInfo

-- | Format a <a>UTCTime</a> in W3 format.
formatW3 :: UTCTime -> Text

-- | Format as per RFC 1123.
formatRFC1123 :: UTCTime -> Text

-- | Format as per RFC 822.
formatRFC822 :: UTCTime -> Text
class RenderRoute a => RouteAttrs a
routeAttrs :: RouteAttrs a => Route a -> Set Text
class RenderRoute a => ParseRoute a
parseRoute :: ParseRoute a => ([Text], [(Text, Text)]) -> Maybe Route a

-- | The <a>type-safe URLs</a> associated with a site argument.

-- | A handler monad for subsite
data SubHandlerFor sub master a

-- | Headers to be added to a <tt>Result</tt>.
data Header
AddCookie :: !SetCookie -> Header

-- | name and path
DeleteCookie :: !ByteString -> !ByteString -> Header

-- | key and value
Header :: !CI ByteString -> !ByteString -> Header

-- | Responses to indicate some form of an error occurred.
data ErrorResponse
NotFound :: ErrorResponse
InternalError :: !Text -> ErrorResponse
InvalidArgs :: ![Text] -> ErrorResponse
NotAuthenticated :: ErrorResponse
PermissionDenied :: !Text -> ErrorResponse
BadMethod :: !Method -> ErrorResponse

-- | Prevents a response body from being fully evaluated before sending the
--   request.
--   
--   Since 1.1.0
newtype DontFullyEvaluate a
DontFullyEvaluate :: a -> DontFullyEvaluate a
[unDontFullyEvaluate] :: DontFullyEvaluate a -> a
type ContentType = ByteString
newtype RepXml
RepXml :: Content -> RepXml
newtype RepPlain
RepPlain :: Content -> RepPlain
newtype RepJson
RepJson :: Content -> RepJson
type RepHtml = Html
data TypedContent
TypedContent :: !ContentType -> !Content -> TypedContent
data Content

-- | The content and optional content length.
ContentBuilder :: !Builder -> !Maybe Int -> Content
ContentSource :: !ConduitT () Flush Builder ResourceT IO () -> Content
ContentFile :: !FilePath -> !Maybe FilePart -> Content
ContentDontEvaluate :: !Content -> Content

-- | Content for a web page. By providing this datatype, we can easily
--   create generic site templates, which would have the type signature:
--   
--   <pre>
--   PageContent url -&gt; HtmlUrl url
--   </pre>
data PageContent url
PageContent :: !Html -> !HtmlUrl url -> !HtmlUrl url -> PageContent url
[pageTitle] :: PageContent url -> !Html
[pageHead] :: PageContent url -> !HtmlUrl url
[pageBody] :: PageContent url -> !HtmlUrl url

-- | Newtype wrapper allowing injection of arbitrary content into CSS.
--   
--   Usage:
--   
--   <pre>
--   toWidget $ CssBuilder "p { color: red }"
--   </pre>
--   
--   Since: 1.1.3
newtype CssBuilder
CssBuilder :: Builder -> CssBuilder
[unCssBuilder] :: CssBuilder -> Builder

-- | A generic widget, allowing specification of both the subsite and
--   master site datatypes. While this is simply a <tt>WriterT</tt>, we
--   define a newtype for better error messages.
data WidgetFor site a

-- | A generic handler monad, which can have a different subsite and master
--   site. We define a newtype for better error message.
data HandlerFor site a

-- | Like <a>WaiSubsite</a>, but applies parent site's middleware and
--   isAuthorized.
newtype WaiSubsiteWithAuth
WaiSubsiteWithAuth :: Application -> WaiSubsiteWithAuth
[runWaiSubsiteWithAuth] :: WaiSubsiteWithAuth -> Application

-- | Wrap up a normal WAI application as a Yesod subsite. Ignore parent
--   site's middleware and isAuthorized.
newtype WaiSubsite
WaiSubsite :: Application -> WaiSubsite
[runWaiSubsite] :: WaiSubsite -> Application
type Texts = [Text]
type BottomOfHeadAsync master = [Text] -> Maybe HtmlUrl Route master -> HtmlUrl Route master
data ScriptLoadPosition master
BottomOfBody :: ScriptLoadPosition master
BottomOfHeadBlocking :: ScriptLoadPosition master
BottomOfHeadAsync :: !BottomOfHeadAsync master -> ScriptLoadPosition master
data AuthResult
Authorized :: AuthResult
AuthenticationRequired :: AuthResult
Unauthorized :: !Text -> AuthResult

-- | How to determine the root of the application for constructing URLs.
--   
--   Note that future versions of Yesod may add new constructors without
--   bumping the major version number. As a result, you should <i>not</i>
--   pattern match on <tt>Approot</tt> values.
data Approot master

-- | No application root.
ApprootRelative :: Approot master
ApprootStatic :: !Text -> Approot master
ApprootMaster :: !master -> Text -> Approot master
ApprootRequest :: !master -> Request -> Text -> Approot master
data FileUpload
FileUploadMemory :: !BackEnd ByteString -> FileUpload
FileUploadDisk :: !InternalState -> BackEnd FilePath -> FileUpload
FileUploadSource :: !BackEnd ConduitT () ByteString ResourceT IO () -> FileUpload
data FileInfo

-- | A tuple containing both the POST parameters and submitted files.
type RequestBodyContents = ([(Text, Text)], [(Text, FileInfo)])

-- | The parsed request information. This type augments the standard WAI
--   <a>Request</a> with additional information.
data YesodRequest
YesodRequest :: ![(Text, Text)] -> ![(Text, Text)] -> !Request -> ![Text] -> !Maybe Text -> !SessionMap -> ![ContentType] -> YesodRequest

-- | Same as <a>queryString</a>, but decoded to <tt>Text</tt>.
[reqGetParams] :: YesodRequest -> ![(Text, Text)]
[reqCookies] :: YesodRequest -> ![(Text, Text)]
[reqWaiRequest] :: YesodRequest -> !Request

-- | Languages which the client supports. This is an ordered list by
--   preference.
[reqLangs] :: YesodRequest -> ![Text]

-- | A random, session-specific token used to prevent CSRF attacks.
[reqToken] :: YesodRequest -> !Maybe Text

-- | Initial session sent from the client.
--   
--   Since 1.2.0
[reqSession] :: YesodRequest -> !SessionMap

-- | An ordered list of the accepted content types.
--   
--   Since 1.2.0
[reqAccept] :: YesodRequest -> ![ContentType]
newtype SessionBackend
SessionBackend :: Request -> IO (SessionMap, SaveSession) -> SessionBackend

-- | Return the session data and a function to save the session
[sbLoadSession] :: SessionBackend -> Request -> IO (SessionMap, SaveSession)
type SessionMap = Map Text ByteString
clientSessionDateCacher :: NominalDiffTime -> IO (IO ClientSessionDateCache, IO ())

-- | Any type which can be converted to <a>TypedContent</a>.
--   
--   Since 1.2.0
class ToContent a => ToTypedContent a
toTypedContent :: ToTypedContent a => a -> TypedContent
class ToTypedContent a => HasContentType a
getContentType :: (HasContentType a, Monad m) => m a -> ContentType

-- | A class for all data which can be sent in a streaming response. Note
--   that for textual data, instances must use UTF-8 encoding.
--   
--   Since 1.2.0
class ToFlushBuilder a
toFlushBuilder :: ToFlushBuilder a => a -> Flush Builder

-- | Anything which can be converted into <a>Content</a>. Most of the time,
--   you will want to use the <a>ContentBuilder</a> constructor. An easier
--   approach will be to use a pre-defined <a>toContent</a> function, such
--   as converting your data into a lazy bytestring and then calling
--   <a>toContent</a> on that.
--   
--   Please note that the built-in instances for lazy data structures
--   (<a>String</a>, lazy <a>ByteString</a>, lazy <a>Text</a> and
--   <a>Html</a>) will not automatically include the content length for the
--   <a>ContentBuilder</a> constructor.
class ToContent a
toContent :: ToContent a => a -> Content

-- | Zero-length enumerator.
emptyContent :: Content
repJson :: ToContent a => a -> RepJson
repPlain :: ToContent a => a -> RepPlain
repXml :: ToContent a => a -> RepXml
typeHtml :: ContentType
typePlain :: ContentType
typeJson :: ContentType
typeXml :: ContentType
typeAtom :: ContentType
typeRss :: ContentType
typeJpeg :: ContentType
typePng :: ContentType
typeGif :: ContentType
typeSvg :: ContentType
typeJavascript :: ContentType
typeCss :: ContentType
typeFlv :: ContentType
typeOgv :: ContentType
typeOctet :: ContentType

-- | Removes "extra" information at the end of a content type string. In
--   particular, removes everything after the semicolon, if present.
--   
--   For example, "text/html; charset=utf-8" is commonly used to specify
--   the character encoding for HTML data. This function would return
--   "text/html".
simpleContentType :: ContentType -> ContentType

-- | Give just the media types as a pair.
--   
--   For example, "text/html; charset=utf-8" returns ("text", "html")
contentTypeTypes :: ContentType -> (ByteString, ByteString)
class MonadHandler m => MonadWidget (m :: * -> *)
liftWidget :: MonadWidget m => WidgetFor HandlerSite m a -> m a
class (MonadResource m, MonadLogger m) => MonadHandler (m :: * -> *) where {
    type family HandlerSite (m :: * -> *) :: *;
    type family SubHandlerSite (m :: * -> *) :: *;
}
liftHandler :: MonadHandler m => HandlerFor HandlerSite m a -> m a
liftSubHandler :: MonadHandler m => SubHandlerFor SubHandlerSite m HandlerSite m a -> m a

-- | Internal representation of a single provided representation.
data ProvidedRep (m :: * -> *)

-- | Add a fragment identifier to a route to be used when redirecting. For
--   example:
--   
--   <pre>
--   redirect (NewsfeedR :#: storyId)
--   </pre>
--   
--   @since 1.2.9.
data Fragment a b
(:#:) :: a -> b -> Fragment a b

-- | Some value which can be turned into a URL for redirects.
class RedirectUrl master a

-- | Converts the value to the URL and a list of query-string parameters.
toTextUrl :: (RedirectUrl master a, MonadHandler m, HandlerSite m ~ master) => a -> m Text
type HandlerT site (m :: * -> *) = HandlerFor site
getRequest :: MonadHandler m => m YesodRequest
runRequestBody :: MonadHandler m => m RequestBodyContents

-- | Get the master site application argument.
getYesod :: MonadHandler m => m HandlerSite m

-- | Get a specific component of the master site application argument.
--   Analogous to the <tt>gets</tt> function for operating on
--   <tt>StateT</tt>.
getsYesod :: MonadHandler m => HandlerSite m -> a -> m a

-- | Get the URL rendering function.
getUrlRender :: MonadHandler m => m Route HandlerSite m -> Text

-- | The URL rendering function with query-string parameters.
getUrlRenderParams :: MonadHandler m => m Route HandlerSite m -> [(Text, Text)] -> Text

-- | Get all the post parameters passed to the handler. To also get the
--   submitted files (if any), you have to use <a>runRequestBody</a>
--   instead of this function.
getPostParams :: MonadHandler m => m [(Text, Text)]

-- | Get the route requested by the user. If this is a 404 response- where
--   the user requested an invalid route- this function will return
--   <a>Nothing</a>.
getCurrentRoute :: MonadHandler m => m Maybe Route HandlerSite m

-- | Returns a function that runs <a>HandlerT</a> actions inside
--   <tt>IO</tt>.
--   
--   Sometimes you want to run an inner <a>HandlerT</a> action outside the
--   control flow of an HTTP request (on the outer <a>HandlerT</a> action).
--   For example, you may want to spawn a new thread:
--   
--   <pre>
--   getFooR :: Handler RepHtml
--   getFooR = do
--     runInnerHandler &lt;- handlerToIO
--     liftIO $ forkIO $ runInnerHandler $ do
--       <i>Code here runs inside GHandler but on a new thread.</i>
--       <i>This is the inner GHandler.</i>
--       ...
--     <i>Code here runs inside the request's control flow.</i>
--     <i>This is the outer GHandler.</i>
--     ...
--   </pre>
--   
--   Another use case for this function is creating a stream of server-sent
--   events using <tt>GHandler</tt> actions (see
--   <tt>yesod-eventsource</tt>).
--   
--   Most of the environment from the outer <tt>GHandler</tt> is preserved
--   on the inner <tt>GHandler</tt>, however:
--   
--   <ul>
--   <li>The request body is cleared (otherwise it would be very difficult
--   to prevent huge memory leaks).</li>
--   <li>The cache is cleared (see <tt>CacheKey</tt>).</li>
--   </ul>
--   
--   Changes to the response made inside the inner <tt>GHandler</tt> are
--   ignored (e.g., session variables, cookies, response headers). This
--   allows the inner <tt>GHandler</tt> to outlive the outer
--   <tt>GHandler</tt> (e.g., on the <tt>forkIO</tt> example above, a
--   response may be sent to the client without killing the new thread).
handlerToIO :: MonadIO m => HandlerFor site HandlerFor site a -> m a

-- | forkIO for a Handler (run an action in the background)
--   
--   Uses <a>handlerToIO</a>, liftResourceT, and resourceForkIO for
--   correctness and efficiency
forkHandler :: () => SomeException -> HandlerFor site () -> HandlerFor site () -> HandlerFor site ()

-- | Redirect to the given route. HTTP status code 303 for HTTP 1.1 clients
--   and 302 for HTTP 1.0 This is the appropriate choice for a
--   get-following-post technique, which should be the usual use case.
--   
--   If you want direct control of the final status code, or need a
--   different status code, please use <a>redirectWith</a>.
redirect :: (MonadHandler m, RedirectUrl HandlerSite m url) => url -> m a

-- | Redirect to the given URL with the specified status code.
redirectWith :: (MonadHandler m, RedirectUrl HandlerSite m url) => Status -> url -> m a

-- | Sets the ultimate destination variable to the given route.
--   
--   An ultimate destination is stored in the user session and can be
--   loaded later by <a>redirectUltDest</a>.
setUltDest :: (MonadHandler m, RedirectUrl HandlerSite m url) => url -> m ()

-- | Same as <a>setUltDest</a>, but uses the current page.
--   
--   If this is a 404 handler, there is no current page, and then this call
--   does nothing.
setUltDestCurrent :: MonadHandler m => m ()

-- | Sets the ultimate destination to the referer request header, if
--   present.
--   
--   This function will not overwrite an existing ultdest.
setUltDestReferer :: MonadHandler m => m ()

-- | Redirect to the ultimate destination in the user's session. Clear the
--   value from the session.
--   
--   The ultimate destination is set with <a>setUltDest</a>.
--   
--   This function uses <a>redirect</a>, and thus will perform a temporary
--   redirect to a GET request.
redirectUltDest :: (RedirectUrl HandlerSite m url, MonadHandler m) => url -> m a

-- | Remove a previously set ultimate destination. See <a>setUltDest</a>.
clearUltDest :: MonadHandler m => m ()

-- | Adds a status and message in the user's session.
--   
--   See <a>getMessages</a>.
addMessage :: MonadHandler m => Text -> Html -> m ()

-- | Adds a message in the user's session but uses RenderMessage to allow
--   for i18n
--   
--   See <a>getMessages</a>.
addMessageI :: (MonadHandler m, RenderMessage HandlerSite m msg) => Text -> msg -> m ()

-- | Gets all messages in the user's session, and then clears the variable.
--   
--   See <a>addMessage</a>.
getMessages :: MonadHandler m => m [(Text, Html)]

-- | Calls <a>addMessage</a> with an empty status
setMessage :: MonadHandler m => Html -> m ()

-- | Calls <a>addMessageI</a> with an empty status
setMessageI :: (MonadHandler m, RenderMessage HandlerSite m msg) => msg -> m ()

-- | Gets just the last message in the user's session, discards the rest
--   and the status
getMessage :: MonadHandler m => m Maybe Html

-- | Bypass remaining handler code and output the given file.
--   
--   For some backends, this is more efficient than reading in the file to
--   memory, since they can optimize file sending via a system call to
--   sendfile.
sendFile :: MonadHandler m => ContentType -> FilePath -> m a

-- | Same as <a>sendFile</a>, but only sends part of a file.
sendFilePart :: MonadHandler m => ContentType -> FilePath -> Integer -> Integer -> m a

-- | Bypass remaining handler code and output the given content with a 200
--   status code.
sendResponse :: (MonadHandler m, ToTypedContent c) => c -> m a

-- | Bypass remaining handler code and output the given content with the
--   given status code.
sendResponseStatus :: (MonadHandler m, ToTypedContent c) => Status -> c -> m a

-- | Bypass remaining handler code and output the given JSON with the given
--   status code.
sendStatusJSON :: (MonadHandler m, ToJSON c) => Status -> c -> m a

-- | Send a 201 <a>Created</a> response with the given route as the
--   Location response header.
sendResponseCreated :: MonadHandler m => Route HandlerSite m -> m a

-- | Bypass remaining handler code and output no content with a 204 status
--   code.
sendResponseNoContent :: MonadHandler m => m a

-- | Send a <a>Response</a>. Please note: this function is rarely
--   necessary, and will <i>disregard</i> any changes to response headers
--   and session that you have already specified. This function
--   short-circuits. It should be considered only for very specific needs.
--   If you are not sure if you need it, you don't.
sendWaiResponse :: MonadHandler m => Response -> m b

-- | Switch over to handling the current request with a WAI
--   <tt>Application</tt>.
sendWaiApplication :: MonadHandler m => Application -> m b

-- | Send a raw response without conduit. This is used for cases such as
--   WebSockets. Requires WAI 3.0 or later, and a web server which supports
--   raw responses (e.g., Warp).
sendRawResponseNoConduit :: (MonadHandler m, MonadUnliftIO m) => IO ByteString -> ByteString -> IO () -> m () -> m a

-- | Send a raw response. This is used for cases such as WebSockets.
--   Requires WAI 2.1 or later, and a web server which supports raw
--   responses (e.g., Warp).
sendRawResponse :: (MonadHandler m, MonadUnliftIO m) => ConduitT () ByteString IO () -> ConduitT ByteString Void IO () -> m () -> m a

-- | Send a 304 not modified response immediately. This is a
--   short-circuiting action.
notModified :: MonadHandler m => m a

-- | Return a 404 not found page. Also denotes no handler available.
notFound :: MonadHandler m => m a

-- | Return a 405 method not supported page.
badMethod :: MonadHandler m => m a

-- | Return a 401 status code
notAuthenticated :: MonadHandler m => m a

-- | Return a 403 permission denied page.
permissionDenied :: MonadHandler m => Text -> m a

-- | Return a 403 permission denied page.
permissionDeniedI :: (RenderMessage HandlerSite m msg, MonadHandler m) => msg -> m a

-- | Return a 400 invalid arguments page.
invalidArgs :: MonadHandler m => [Text] -> m a

-- | Return a 400 invalid arguments page.
invalidArgsI :: (MonadHandler m, RenderMessage HandlerSite m msg) => [msg] -> m a

-- | Set the cookie on the client.
setCookie :: MonadHandler m => SetCookie -> m ()

-- | Helper function for setCookieExpires value
getExpires :: MonadIO m => Int -> m UTCTime

-- | Unset the cookie on the client.
--   
--   Note: although the value used for key and path is <a>Text</a>, you
--   should only use ASCII values to be HTTP compliant.
deleteCookie :: MonadHandler m => Text -> Text -> m ()

-- | Set the language in the user session. Will show up in <a>languages</a>
--   on the next request.
setLanguage :: MonadHandler m => Text -> m ()

-- | Set attachment file name.
--   
--   Allows Unicode characters by encoding to UTF-8. Some modurn browser
--   parse UTF-8 characters with out encoding setting. But, for example IE9
--   can't parse UTF-8 characters. This function use <a>RFC 6266</a>(<a>RFC
--   5987</a>)
addContentDispositionFileName :: MonadHandler m => Text -> m ()

-- | Set an arbitrary response header.
--   
--   Note that, while the data type used here is <a>Text</a>, you must
--   provide only ASCII value to be HTTP compliant.
addHeader :: MonadHandler m => Text -> Text -> m ()

-- | Deprecated synonym for addHeader.
setHeader :: MonadHandler m => Text -> Text -> m ()

-- | Replace an existing header with a new value or add a new header if not
--   present.
--   
--   Note that, while the data type used here is <a>Text</a>, you must
--   provide only ASCII value to be HTTP compliant.
replaceOrAddHeader :: MonadHandler m => Text -> Text -> m ()

-- | Set the Cache-Control header to indicate this response should be
--   cached for the given number of seconds.
cacheSeconds :: MonadHandler m => Int -> m ()

-- | Set the Expires header to some date in 2037. In other words, this
--   content is never (realistically) expired.
neverExpires :: MonadHandler m => m ()

-- | Set an Expires header in the past, meaning this content should not be
--   cached.
alreadyExpired :: MonadHandler m => m ()

-- | Set an Expires header to the given date.
expiresAt :: MonadHandler m => UTCTime -> m ()

-- | Check the if-none-match header and, if it matches the given value,
--   return a 304 not modified response. Otherwise, set the etag header to
--   the given value.
--   
--   Note that it is the responsibility of the caller to ensure that the
--   provided value is a valid etag value, no sanity checking is performed
--   by this function.
setEtag :: MonadHandler m => Text -> m ()

-- | Check the if-none-match header and, if it matches the given value,
--   return a 304 not modified response. Otherwise, set the etag header to
--   the given value.
--   
--   A weak etag is only expected to be semantically identical to the prior
--   content, but doesn't have to be byte-for-byte identical. Therefore it
--   can be useful for dynamically generated content that may be difficult
--   to perform bytewise hashing upon.
--   
--   Note that it is the responsibility of the caller to ensure that the
--   provided value is a valid etag value, no sanity checking is performed
--   by this function.
setWeakEtag :: MonadHandler m => Text -> m ()

-- | Set a variable in the user's session.
--   
--   The session is handled by the clientsession package: it sets an
--   encrypted and hashed cookie on the client. This ensures that all data
--   is secure and not tampered with.
setSession :: MonadHandler m => Text -> Text -> m ()

-- | Same as <a>setSession</a>, but uses binary data for the value.
setSessionBS :: MonadHandler m => Text -> ByteString -> m ()

-- | Unsets a session variable. See <a>setSession</a>.
deleteSession :: MonadHandler m => Text -> m ()

-- | Clear all session variables.
--   
--   @since: 1.0.1
clearSession :: MonadHandler m => m ()

-- | Lookup for session data.
lookupSession :: MonadHandler m => Text -> m Maybe Text

-- | Lookup for session data in binary format.
lookupSessionBS :: MonadHandler m => Text -> m Maybe ByteString

-- | Get all session variables.
getSession :: MonadHandler m => m SessionMap

-- | Get a unique identifier.
newIdent :: MonadHandler m => m Text

-- | Redirect to a POST resource.
--   
--   This is not technically a redirect; instead, it returns an HTML page
--   with a POST form, and some Javascript to automatically submit the
--   form. This can be useful when you need to post a plain link somewhere
--   that needs to cause changes on the server.
redirectToPost :: (MonadHandler m, RedirectUrl HandlerSite m url) => url -> m a

-- | Wraps the <a>Content</a> generated by <tt>hamletToContent</tt> in a
--   <a>RepHtml</a>.
hamletToRepHtml :: MonadHandler m => HtmlUrl Route HandlerSite m -> m Html

-- | Deprecated synonym for <a>withUrlRenderer</a>.
giveUrlRenderer :: MonadHandler m => Route HandlerSite m -> [(Text, Text)] -> Text -> output -> m output

-- | Provide a URL rendering function to the given function and return the
--   result. Useful for processing Shakespearean templates.
withUrlRenderer :: MonadHandler m => Route HandlerSite m -> [(Text, Text)] -> Text -> output -> m output

-- | Get the request's <a>Request</a> value.
waiRequest :: MonadHandler m => m Request
getMessageRender :: (MonadHandler m, RenderMessage HandlerSite m message) => m message -> Text

-- | Use a per-request cache to avoid performing the same action multiple
--   times. Values are stored by their type, the result of typeOf from
--   Typeable. Therefore, you should use different newtype wrappers at each
--   cache site.
--   
--   For example, yesod-auth uses an un-exported newtype, CachedMaybeAuth
--   and exports functions that utilize it such as maybeAuth. This means
--   that another module can create its own newtype wrapper to cache the
--   same type from a different action without any cache conflicts.
--   
--   See the original announcement:
--   <a>http://www.yesodweb.com/blog/2013/03/yesod-1-2-cleaner-internals</a>
cached :: (MonadHandler m, Typeable a) => m a -> m a

-- | a per-request cache. just like <a>cached</a>. <a>cached</a> can only
--   cache a single value per type. <a>cachedBy</a> stores multiple values
--   per type by usage of a ByteString key
--   
--   <a>cached</a> is ideal to cache an action that has only one value of a
--   type, such as the session's current user <a>cachedBy</a> is required
--   if the action has parameters and can return multiple values per type.
--   You can turn those parameters into a ByteString cache key. For
--   example, caching a lookup of a Link by a token where multiple token
--   lookups might be performed.
cachedBy :: (MonadHandler m, Typeable a) => ByteString -> m a -> m a

-- | Get the list of supported languages supplied by the user.
--   
--   Languages are determined based on the following (in descending order
--   of preference):
--   
--   <ul>
--   <li>The _LANG user session variable.</li>
--   <li>The _LANG get parameter.</li>
--   <li>The _LANG cookie.</li>
--   <li>Accept-Language HTTP header.</li>
--   </ul>
--   
--   Yesod will seek the first language from the returned list matched with
--   languages supporting by your application. This language will be used
--   to render i18n templates. If a matching language is not found the
--   default language will be used.
--   
--   This is handled by parseWaiRequest (not exposed).
languages :: MonadHandler m => m [Text]

-- | Lookup a request header.
lookupHeader :: MonadHandler m => CI ByteString -> m Maybe ByteString

-- | Lookup a request header.
lookupHeaders :: MonadHandler m => CI ByteString -> m [ByteString]

-- | Lookup basic authentication data from <b>Authorization</b> header of
--   request. Returns user name and password
lookupBasicAuth :: MonadHandler m => m Maybe (Text, Text)

-- | Lookup bearer authentication datafrom <b>Authorization</b> header of
--   request. Returns bearer token value
lookupBearerAuth :: MonadHandler m => m Maybe Text

-- | Lookup for GET parameters.
lookupGetParams :: MonadHandler m => Text -> m [Text]

-- | Lookup for GET parameters.
lookupGetParam :: MonadHandler m => Text -> m Maybe Text

-- | Lookup for POST parameters.
lookupPostParams :: (MonadResource m, MonadHandler m) => Text -> m [Text]
lookupPostParam :: (MonadResource m, MonadHandler m) => Text -> m Maybe Text

-- | Lookup for POSTed files.
lookupFile :: MonadHandler m => Text -> m Maybe FileInfo

-- | Lookup for POSTed files.
lookupFiles :: MonadHandler m => Text -> m [FileInfo]

-- | Lookup for cookie data.
lookupCookie :: MonadHandler m => Text -> m Maybe Text

-- | Lookup for cookie data.
lookupCookies :: MonadHandler m => Text -> m [Text]

-- | Select a representation to send to the client based on the
--   representations provided inside this do-block. Should be used together
--   with <a>provideRep</a>.
selectRep :: MonadHandler m => Writer Endo [ProvidedRep m] () -> m TypedContent

-- | Provide a single representation to be used, based on the request of
--   the client. Should be used together with <a>selectRep</a>.
provideRep :: (Monad m, HasContentType a) => m a -> Writer Endo [ProvidedRep m] ()

-- | Same as <a>provideRep</a>, but instead of determining the content type
--   from the type of the value itself, you provide the content type
--   separately. This can be a convenience instead of creating newtype
--   wrappers for uncommonly used content types.
--   
--   <pre>
--   provideRepType "application/x-special-format" "This is the content"
--   </pre>
provideRepType :: (Monad m, ToContent a) => ContentType -> m a -> Writer Endo [ProvidedRep m] ()

-- | Stream in the raw request body without any parsing.
rawRequestBody :: MonadHandler m => ConduitT i ByteString m ()

-- | Stream the data from the file. Since Yesod 1.2, this has been
--   generalized to work in any <tt>MonadResource</tt>.
fileSource :: MonadResource m => FileInfo -> ConduitT () ByteString m ()

-- | Extract a strict <tt>ByteString</tt> body from a <a>FileInfo</a>.
--   
--   This function will block while reading the file.
--   
--   <pre>
--   do
--       fileByteString &lt;- fileSourceByteString fileInfo
--   </pre>
fileSourceByteString :: MonadResource m => FileInfo -> m ByteString

-- | Provide a pure value for the response body.
--   
--   <pre>
--   respond ct = return . TypedContent ct . toContent
--   </pre>
respond :: (Monad m, ToContent a) => ContentType -> a -> m TypedContent

-- | Use a <tt>Source</tt> for the response body.
--   
--   Note that, for ease of use, the underlying monad is a
--   <tt>HandlerT</tt>. This implies that you can run any <tt>HandlerT</tt>
--   action. However, since a streaming response occurs after the response
--   headers have already been sent, some actions make no sense here. For
--   example: short-circuit responses, setting headers, changing status
--   codes, etc.
respondSource :: () => ContentType -> ConduitT () Flush Builder HandlerFor site () -> HandlerFor site TypedContent

-- | In a streaming response, send a single chunk of data. This function
--   works on most datatypes, such as <tt>ByteString</tt> and
--   <tt>Html</tt>.
sendChunk :: (Monad m, ToFlushBuilder a) => a -> ConduitT i Flush Builder m ()

-- | In a streaming response, send a flush command, causing all buffered
--   data to be immediately sent to the client.
sendFlush :: Monad m => ConduitT i Flush Builder m ()

-- | Type-specialized version of <a>sendChunk</a> for strict
--   <tt>ByteString</tt>s.
sendChunkBS :: Monad m => ByteString -> ConduitT i Flush Builder m ()

-- | Type-specialized version of <a>sendChunk</a> for lazy
--   <tt>ByteString</tt>s.
sendChunkLBS :: Monad m => ByteString -> ConduitT i Flush Builder m ()

-- | Type-specialized version of <a>sendChunk</a> for strict
--   <tt>Text</tt>s.
sendChunkText :: Monad m => Text -> ConduitT i Flush Builder m ()

-- | Type-specialized version of <a>sendChunk</a> for lazy <tt>Text</tt>s.
sendChunkLazyText :: Monad m => Text -> ConduitT i Flush Builder m ()

-- | Type-specialized version of <a>sendChunk</a> for <tt>Html</tt>s.
sendChunkHtml :: Monad m => Html -> ConduitT i Flush Builder m ()

-- | The default cookie name for the CSRF token ("XSRF-TOKEN").
defaultCsrfCookieName :: ByteString

-- | Sets a cookie with a CSRF token, using <a>defaultCsrfCookieName</a>
--   for the cookie name.
--   
--   The cookie's path is set to <tt>/</tt>, making it valid for your whole
--   website.
setCsrfCookie :: MonadHandler m => m ()

-- | Takes a <a>SetCookie</a> and overrides its value with a CSRF token,
--   then sets the cookie.
--   
--   Make sure to set the <a>setCookiePath</a> to the root path of your
--   application, otherwise you'll generate a new CSRF token for every path
--   of your app. If your app is run from from e.g. www.example.com/app1,
--   use <tt>app1</tt>. The vast majority of sites will just use
--   <tt>/</tt>.
setCsrfCookieWithCookie :: MonadHandler m => SetCookie -> m ()

-- | The default header name for the CSRF token ("X-XSRF-TOKEN").
defaultCsrfHeaderName :: CI ByteString

-- | Takes a header name to lookup a CSRF token. If the value doesn't match
--   the token stored in the session, this function throws a
--   <a>PermissionDenied</a> error.
checkCsrfHeaderNamed :: MonadHandler m => CI ByteString -> m ()

-- | Takes a header name to lookup a CSRF token, and returns whether the
--   value matches the token stored in the session.
hasValidCsrfHeaderNamed :: MonadHandler m => CI ByteString -> m Bool

-- | The default parameter name for the CSRF token ("_token")
defaultCsrfParamName :: Text

-- | Takes a POST parameter name to lookup a CSRF token. If the value
--   doesn't match the token stored in the session, this function throws a
--   <a>PermissionDenied</a> error.
checkCsrfParamNamed :: MonadHandler m => Text -> m ()

-- | Takes a POST parameter name to lookup a CSRF token, and returns
--   whether the value matches the token stored in the session.
hasValidCsrfParamNamed :: MonadHandler m => Text -> m Bool

-- | Checks that a valid CSRF token is present in either the request
--   headers or POST parameters. If the value doesn't match the token
--   stored in the session, this function throws a <a>PermissionDenied</a>
--   error.
checkCsrfHeaderOrParam :: (MonadHandler m, MonadLogger m) => CI ByteString -> Text -> m ()
getSubYesod :: MonadHandler m => m SubHandlerSite m
getRouteToParent :: MonadHandler m => m Route SubHandlerSite m -> Route HandlerSite m
getSubCurrentRoute :: MonadHandler m => m Maybe Route SubHandlerSite m
class ToWidgetHead site a
toWidgetHead :: (ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) => a -> m ()
class ToWidgetBody site a
toWidgetBody :: (ToWidgetBody site a, MonadWidget m, HandlerSite m ~ site) => a -> m ()

-- | Allows adding some CSS to the page with a specific media type.
--   
--   Since 1.2
class ToWidgetMedia site a

-- | Add the given content to the page, but only for the given media type.
--   
--   Since 1.2
toWidgetMedia :: (ToWidgetMedia site a, MonadWidget m, HandlerSite m ~ site) => Text -> a -> m ()
class ToWidget site a
toWidget :: (ToWidget site a, MonadWidget m, HandlerSite m ~ site) => a -> m ()
type WidgetT site (m :: * -> *) = WidgetFor site

-- | Set the page title. Calling <a>setTitle</a> multiple times overrides
--   previously set values.
setTitle :: MonadWidget m => Html -> m ()

-- | Set the page title. Calling <a>setTitle</a> multiple times overrides
--   previously set values.
setTitleI :: (MonadWidget m, RenderMessage HandlerSite m msg) => msg -> m ()

-- | Link to the specified local stylesheet.
addStylesheet :: MonadWidget m => Route HandlerSite m -> m ()

-- | Link to the specified local stylesheet.
addStylesheetAttrs :: MonadWidget m => Route HandlerSite m -> [(Text, Text)] -> m ()

-- | Link to the specified remote stylesheet.
addStylesheetRemote :: MonadWidget m => Text -> m ()

-- | Link to the specified remote stylesheet.
addStylesheetRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()
addStylesheetEither :: MonadWidget m => Either Route HandlerSite m Text -> m ()
addScriptEither :: MonadWidget m => Either Route HandlerSite m Text -> m ()

-- | Link to the specified local script.
addScript :: MonadWidget m => Route HandlerSite m -> m ()

-- | Link to the specified local script.
addScriptAttrs :: MonadWidget m => Route HandlerSite m -> [(Text, Text)] -> m ()

-- | Link to the specified remote script.
addScriptRemote :: MonadWidget m => Text -> m ()

-- | Link to the specified remote script.
addScriptRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()
whamlet :: QuasiQuoter
whamletFile :: FilePath -> Q Exp
whamletFileWithSettings :: HamletSettings -> FilePath -> Q Exp
asWidgetT :: () => WidgetT site m () -> WidgetT site m ()

-- | Wraps the <a>Content</a> generated by <tt>hamletToContent</tt> in a
--   <a>RepHtml</a>.
ihamletToRepHtml :: (MonadHandler m, RenderMessage HandlerSite m message) => HtmlUrlI18n message Route HandlerSite m -> m Html

-- | Wraps the <a>Content</a> generated by <tt>hamletToContent</tt> in a
--   <a>RepHtml</a>.
--   
--   Since 1.2.1
ihamletToHtml :: (MonadHandler m, RenderMessage HandlerSite m message) => HtmlUrlI18n message Route HandlerSite m -> m Html
handlerToWidget :: () => HandlerFor site a -> WidgetFor site a

-- | Define settings for a Yesod applications. All methods have intelligent
--   defaults, and therefore no implementation is required.
class RenderRoute site => Yesod site

-- | An absolute URL to the root of the application. Do not include
--   trailing slash.
--   
--   Default value: <a>guessApproot</a>. If you know your application root
--   statically, it will be more efficient and more reliable to instead use
--   <a>ApprootStatic</a> or <a>ApprootMaster</a>. If you do not need full
--   absolute URLs, you can use <a>ApprootRelative</a> instead.
--   
--   Note: Prior to yesod-core 1.5, the default value was
--   <a>ApprootRelative</a>.
approot :: Yesod site => Approot site

-- | Output error response pages.
--   
--   Default value: <a>defaultErrorHandler</a>.
errorHandler :: Yesod site => ErrorResponse -> HandlerFor site TypedContent

-- | Applies some form of layout to the contents of a page.
defaultLayout :: Yesod site => WidgetFor site () -> HandlerFor site Html

-- | Override the rendering function for a particular URL and query string
--   parameters. One use case for this is to offload static hosting to a
--   different domain name to avoid sending cookies.
--   
--   For backward compatibility default implementation is in terms of
--   <tt>urlRenderOverride</tt>, probably ineffective
--   
--   Since 1.4.23
urlParamRenderOverride :: Yesod site => site -> Route site -> [(Text, Text)] -> Maybe Builder

-- | Determine if a request is authorized or not.
--   
--   Return <a>Authorized</a> if the request is authorized,
--   <a>Unauthorized</a> a message if unauthorized. If authentication is
--   required, return <a>AuthenticationRequired</a>.
isAuthorized :: Yesod site => Route site -> Bool -> HandlerFor site AuthResult

-- | Determines whether the current request is a write request. By default,
--   this assumes you are following RESTful principles, and determines this
--   from request method. In particular, all except the following request
--   methods are considered write: GET HEAD OPTIONS TRACE.
--   
--   This function is used to determine if a request is authorized; see
--   <a>isAuthorized</a>.
isWriteRequest :: Yesod site => Route site -> HandlerFor site Bool

-- | The default route for authentication.
--   
--   Used in particular by <a>isAuthorized</a>, but library users can do
--   whatever they want with it.
authRoute :: Yesod site => site -> Maybe Route site

-- | A function used to clean up path segments. It returns <a>Right</a>
--   with a clean path or <a>Left</a> with a new set of pieces the user
--   should be redirected to. The default implementation enforces:
--   
--   <ul>
--   <li>No double slashes</li>
--   <li>There is no trailing slash.</li>
--   </ul>
--   
--   Note that versions of Yesod prior to 0.7 used a different set of rules
--   involing trailing slashes.
cleanPath :: Yesod site => site -> [Text] -> Either [Text] [Text]

-- | Builds an absolute URL by concatenating the application root with the
--   pieces of a path and a query string, if any. Note that the pieces of
--   the path have been previously cleaned up by <a>cleanPath</a>.
joinPath :: Yesod site => site -> Text -> [Text] -> [(Text, Text)] -> Builder

-- | This function is used to store some static content to be served as an
--   external file. The most common case of this is stashing CSS and
--   JavaScript content in an external file; the <a>Yesod.Widget</a> module
--   uses this feature.
--   
--   The return value is <a>Nothing</a> if no storing was performed; this
--   is the default implementation. A <a>Just</a> <a>Left</a> gives the
--   absolute URL of the file, whereas a <a>Just</a> <a>Right</a> gives the
--   type-safe URL. The former is necessary when you are serving the
--   content outside the context of a Yesod application, such as via
--   memcached.
addStaticContent :: Yesod site => Text -> Text -> ByteString -> HandlerFor site Maybe Either Text (Route site, [(Text, Text)])

-- | Maximum allowed length of the request body, in bytes.
--   
--   If <tt>Nothing</tt>, no maximum is applied.
--   
--   Default: 2 megabytes.
maximumContentLength :: Yesod site => site -> Maybe Route site -> Maybe Word64

-- | Creates a <tt>Logger</tt> to use for log messages.
--   
--   Note that a common technique (endorsed by the scaffolding) is to
--   create a <tt>Logger</tt> value and place it in your foundation
--   datatype, and have this method return that already created value. That
--   way, you can use that same <tt>Logger</tt> for printing messages
--   during app initialization.
--   
--   Default: the <a>defaultMakeLogger</a> function.
makeLogger :: Yesod site => site -> IO Logger

-- | Send a message to the <tt>Logger</tt> provided by <tt>getLogger</tt>.
--   
--   Default: the <a>defaultMessageLoggerSource</a> function, using
--   <a>shouldLogIO</a> to check whether we should log.
messageLoggerSource :: Yesod site => site -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()

-- | Where to Load sripts from. We recommend the default value,
--   <a>BottomOfBody</a>.
jsLoader :: Yesod site => site -> ScriptLoadPosition site

-- | Default attributes to put on the JavaScript <a>script</a> tag
--   generated for julius files
jsAttributes :: Yesod site => site -> [(Text, Text)]

-- | Create a session backend. Returning <a>Nothing</a> disables sessions.
--   If you'd like to change the way that the session cookies are created,
--   take a look at <a>customizeSessionCookies</a>.
--   
--   Default: Uses clientsession with a 2 hour timeout.
makeSessionBackend :: Yesod site => site -> IO Maybe SessionBackend

-- | How to store uploaded files.
--   
--   Default: When the request body is greater than 50kb, store in a temp
--   file. For chunked request bodies, store in a temp file. Otherwise,
--   store in memory.
fileUpload :: Yesod site => site -> RequestBodyLength -> FileUpload

-- | Should we log the given log source/level combination.
--   
--   Default: the <a>defaultShouldLogIO</a> function.
--   
--   Since 1.2.4
shouldLogIO :: Yesod site => site -> LogSource -> LogLevel -> IO Bool

-- | A Yesod middleware, which will wrap every handler function. This
--   allows you to run code before and after a normal handler.
--   
--   Default: the <a>defaultYesodMiddleware</a> function.
--   
--   Since: 1.1.6
yesodMiddleware :: (Yesod site, ToTypedContent res) => HandlerFor site res -> HandlerFor site res

-- | How to allocate an <tt>InternalState</tt> for each request.
--   
--   The default implementation is almost always what you want. However, if
--   you know that you are never taking advantage of the
--   <tt>MonadResource</tt> instance in your handler functions, setting
--   this to a dummy implementation can provide a small optimization. Only
--   do this if you really know what you're doing, otherwise you can turn
--   safe code into a runtime error!
--   
--   Since 1.4.2
yesodWithInternalState :: Yesod site => site -> Maybe Route site -> InternalState -> IO a -> IO a

-- | Convert a title and HTML snippet into a <tt>Widget</tt>. Used
--   primarily for wrapping up error messages for better display.
defaultMessageWidget :: Yesod site => Html -> HtmlUrl Route site -> WidgetFor site ()

-- | Default implementation of <a>makeLogger</a>. Sends to stdout and
--   automatically flushes on each write.
--   
--   Since 1.4.10
defaultMakeLogger :: IO Logger

-- | Default implementation of <a>messageLoggerSource</a>. Checks if the
--   message should be logged using the provided function, and if so,
--   formats using <a>formatLogMessage</a>. You can use
--   <a>defaultShouldLogIO</a> as the provided function.
--   
--   Since 1.4.10
defaultMessageLoggerSource :: LogSource -> LogLevel -> IO Bool -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()

-- | Default implementation of <tt>shouldLog</tt>. Logs everything at or
--   above <a>LevelInfo</a>.
--   
--   Since 1.4.10
defaultShouldLogIO :: LogSource -> LogLevel -> IO Bool

-- | Default implementation of <a>yesodMiddleware</a>. Adds the response
--   header "Vary: Accept, Accept-Language", "X-XSS-Protection: 1;
--   mode=block", and performs authorization checks.
--   
--   Since 1.2.0
defaultYesodMiddleware :: Yesod site => HandlerFor site res -> HandlerFor site res

-- | Defends against session hijacking by setting the secure bit on session
--   cookies so that browsers will not transmit them over http. With this
--   setting on, it follows that the server will regard requests made over
--   http as sessionless, because the session cookie will not be included
--   in the request. Use this as part of a total security measure which
--   also includes disabling HTTP traffic to the site or issuing redirects
--   from HTTP urls, and composing <a>sslOnlyMiddleware</a> with the site's
--   <a>yesodMiddleware</a>.
--   
--   Since 1.4.7
sslOnlySessions :: IO Maybe SessionBackend -> IO Maybe SessionBackend

-- | Helps defend against CSRF attacks by setting the SameSite attribute on
--   session cookies to Lax. With the Lax setting, the cookie will be sent
--   with same-site requests, and with cross-site top-level navigations.
--   
--   This option is liable to change in future versions of Yesod as the
--   spec evolves. View more information <a>here</a>.
laxSameSiteSessions :: IO Maybe SessionBackend -> IO Maybe SessionBackend

-- | Helps defend against CSRF attacks by setting the SameSite attribute on
--   session cookies to Strict. With the Strict setting, the cookie will
--   only be sent with same-site requests.
--   
--   This option is liable to change in future versions of Yesod as the
--   spec evolves. View more information <a>here</a>.
strictSameSiteSessions :: IO Maybe SessionBackend -> IO Maybe SessionBackend

-- | Apply a Strict-Transport-Security header with the specified timeout to
--   all responses so that browsers will rewrite all http links to https
--   until the timeout expires. For security, the max-age of the STS header
--   should always equal or exceed the client sessions timeout. This
--   defends against SSL-stripping man-in-the-middle attacks. It is only
--   effective if a secure connection has already been made;
--   Strict-Transport-Security headers are ignored over HTTP.
--   
--   Since 1.4.7
sslOnlyMiddleware :: () => Int -> HandlerFor site res -> HandlerFor site res

-- | Check if a given request is authorized via <a>isAuthorized</a> and
--   <a>isWriteRequest</a>.
--   
--   Since 1.2.0
authorizationCheck :: Yesod site => HandlerFor site ()

-- | Calls <a>csrfCheckMiddleware</a> with <a>isWriteRequest</a>,
--   <a>defaultCsrfHeaderName</a>, and <a>defaultCsrfParamName</a> as
--   parameters.
--   
--   Since 1.4.14
defaultCsrfCheckMiddleware :: Yesod site => HandlerFor site res -> HandlerFor site res

-- | Looks up the CSRF token from the request headers or POST parameters.
--   If the value doesn't match the token stored in the session, this
--   function throws a <a>PermissionDenied</a> error.
--   
--   For details, see the "AJAX CSRF protection" section of
--   <a>Yesod.Core.Handler</a>.
--   
--   Since 1.4.14
csrfCheckMiddleware :: () => HandlerFor site res -> HandlerFor site Bool -> CI ByteString -> Text -> HandlerFor site res

-- | Calls <a>csrfSetCookieMiddleware</a> with the
--   <a>defaultCsrfCookieName</a>.
--   
--   The cookie's path is set to <tt>/</tt>, making it valid for your whole
--   website.
--   
--   Since 1.4.14
defaultCsrfSetCookieMiddleware :: () => HandlerFor site res -> HandlerFor site res

-- | Takes a <a>SetCookie</a> and overrides its value with a CSRF token,
--   then sets the cookie. See <a>setCsrfCookieWithCookie</a>.
--   
--   For details, see the "AJAX CSRF protection" section of
--   <a>Yesod.Core.Handler</a>.
--   
--   Make sure to set the <a>setCookiePath</a> to the root path of your
--   application, otherwise you'll generate a new CSRF token for every path
--   of your app. If your app is run from from e.g. www.example.com/app1,
--   use <tt>app1</tt>. The vast majority of sites will just use
--   <tt>/</tt>.
--   
--   Since 1.4.14
csrfSetCookieMiddleware :: () => HandlerFor site res -> SetCookie -> HandlerFor site res

-- | Calls <a>defaultCsrfSetCookieMiddleware</a> and
--   <a>defaultCsrfCheckMiddleware</a>.
--   
--   For details, see the "AJAX CSRF protection" section of
--   <a>Yesod.Core.Handler</a>.
--   
--   You can chain this middleware together with other middleware like so:
--   
--   <pre>
--   <a>yesodMiddleware</a> = <a>defaultYesodMiddleware</a> . <a>defaultCsrfMiddleware</a>
--   </pre>
--   
--   or:
--   
--   <pre>
--   <a>yesodMiddleware</a> app = <a>defaultYesodMiddleware</a> $ <a>defaultCsrfMiddleware</a> $ app
--   </pre>
--   
--   Since 1.4.14
defaultCsrfMiddleware :: Yesod site => HandlerFor site res -> HandlerFor site res

-- | Convert a widget to a <a>PageContent</a>.
widgetToPageContent :: Yesod site => WidgetFor site () -> HandlerFor site PageContent Route site

-- | The default error handler for <a>errorHandler</a>.
defaultErrorHandler :: Yesod site => ErrorResponse -> HandlerFor site TypedContent

-- | Default formatting for log messages. When you use the template haskell
--   logging functions for to log with information about the source
--   location, that information will be appended to the end of the log.
--   When you use the non-TH logging functions, like <tt>logDebugN</tt>,
--   this function does not include source information. This currently
--   works by checking to see if the package name is the string
--   "&lt;unknown&gt;". This is a hack, but it removes some of the visual
--   clutter from non-TH logs.
--   
--   Since 1.4.10
formatLogMessage :: IO ZonedDate -> Loc -> LogSource -> LogLevel -> LogStr -> IO LogStr

-- | Customize the cookies used by the session backend. You may use this
--   function on your definition of <a>makeSessionBackend</a>.
--   
--   For example, you could set the cookie domain so that it would work
--   across many subdomains:
--   
--   <pre>
--   makeSessionBackend site =
--       (fmap . fmap) (customizeSessionCookies addDomain) ...
--     where
--       addDomain cookie = cookie { <a>setCookieDomain</a> = Just ".example.com" }
--   </pre>
--   
--   Default: Do not customize anything (<a>id</a>).
customizeSessionCookies :: SetCookie -> SetCookie -> SessionBackend -> SessionBackend
defaultClientSessionBackend :: Int -> FilePath -> IO SessionBackend

-- | Create a <tt>SessionBackend</tt> which reads the session key from the
--   named environment variable.
--   
--   This can be useful if:
--   
--   <ol>
--   <li>You can't rely on a persistent file system (e.g. Heroku)</li>
--   <li>Your application is open source (e.g. you can't commit the
--   key)</li>
--   </ol>
--   
--   By keeping a consistent value in the environment variable, your users
--   will have consistent sessions without relying on the file system.
--   
--   Note: A suitable value should only be obtained in one of two ways:
--   
--   <ol>
--   <li>Run this code without the variable set, a value will be generated
--   and printed on <tt><i>dev</i>stdout/</tt></li>
--   <li>Use <tt>clientsession-generate</tt></li>
--   </ol>
--   
--   Since 1.4.5
envClientSessionBackend :: Int -> String -> IO SessionBackend
clientSessionBackend :: Key -> IO ClientSessionDateCache -> SessionBackend
loadClientSession :: Key -> IO ClientSessionDateCache -> ByteString -> Request -> IO (SessionMap, SaveSession)

-- | Guess the approot based on request headers. For more information, see
--   <a>Network.Wai.Middleware.Approot</a>
--   
--   In the case of headers being unavailable, it falls back to
--   <a>ApprootRelative</a>
--   
--   Since 1.4.16
guessApproot :: () => Approot site

-- | Guess the approot based on request headers, with fall back to the
--   specified <tt>AppRoot</tt>.
--   
--   Since 1.4.16
guessApprootOr :: () => Approot site -> Approot site

-- | Get the textual application root from an <a>Approot</a> value.
--   
--   Since 1.4.17
getApprootText :: () => Approot site -> site -> Request -> Text

-- | Provide both an HTML and JSON representation for a piece of data,
--   using the default layout for the HTML output (<a>defaultLayout</a>).
defaultLayoutJson :: (Yesod site, ToJSON a) => WidgetFor site () -> HandlerFor site a -> HandlerFor site TypedContent

-- | Wraps a data type in a <tt>RepJson</tt>. The data type must support
--   conversion to JSON via <a>ToJSON</a>.
jsonToRepJson :: (Monad m, ToJSON a) => a -> m Value

-- | Convert a value to a JSON representation via aeson's <a>toJSON</a>
--   function.
returnJson :: (Monad m, ToJSON a) => a -> m Value

-- | Convert a value to a JSON representation via aeson's <a>toEncoding</a>
--   function.
returnJsonEncoding :: (Monad m, ToJSON a) => a -> m Encoding

-- | Provide a JSON representation for usage with <tt>selectReps</tt>,
--   using aeson's <a>toJSON</a> (aeson &gt;= 0.11: <a>toEncoding</a>)
--   function to perform the conversion.
provideJson :: (Monad m, ToJSON a) => a -> Writer Endo [ProvidedRep m] ()

-- | Parse the request body to a data type as a JSON value. The data type
--   must support conversion from JSON via <a>FromJSON</a>. If you want the
--   raw JSON value, just ask for a <tt><a>Result</a> <a>Value</a></tt>.
--   
--   Note that this function will consume the request body. As such,
--   calling it twice will result in a parse error on the second call,
--   since the request body will no longer be available.
parseJsonBody :: (MonadHandler m, FromJSON a) => m Result a

-- | Same as <a>parseJsonBody</a>, but ensures that the mime type indicates
--   JSON content.
parseCheckJsonBody :: (MonadHandler m, FromJSON a) => m Result a

-- | Same as <a>parseJsonBody</a>, but return an invalid args response on a
--   parse error.
parseJsonBody_ :: (MonadHandler m, FromJSON a) => m a

-- | Same as <a>parseJsonBody</a>, but return an invalid args response on a
--   parse error.
requireJsonBody :: (MonadHandler m, FromJSON a) => m a

-- | Same as <a>requireJsonBody</a>, but ensures that the MIME type
--   indicates JSON content. Requiring a JSON content-type helps secure
--   your site against CSRF attacks (browsers will perform POST requests
--   for form and text/plain content-types without doing a CORS check, and
--   those content-types can easily contain valid JSON).
requireCheckJsonBody :: (MonadHandler m, FromJSON a) => m a

-- | Convert a list of values to an <a>Array</a>.
array :: ToJSON a => [a] -> Value

-- | jsonOrRedirect simplifies the scenario where a POST handler sends a
--   different response based on Accept headers:
--   
--   <ol>
--   <li>200 with JSON data if the client prefers <tt>application/json</tt>
--   (e.g. AJAX, see <tt>acceptsJSON</tt>).</li>
--   <li>3xx otherwise, following the PRG pattern.</li>
--   </ol>
jsonOrRedirect :: (MonadHandler m, ToJSON a) => Route HandlerSite m -> a -> m Value

-- | jsonEncodingOrRedirect simplifies the scenario where a POST handler
--   sends a different response based on Accept headers:
--   
--   <ol>
--   <li>200 with JSON data if the client prefers <tt>application/json</tt>
--   (e.g. AJAX, see <tt>acceptsJSON</tt>).</li>
--   <li>3xx otherwise, following the PRG pattern. @since 1.4.21</li>
--   </ol>
jsonEncodingOrRedirect :: (MonadHandler m, ToJSON a) => Route HandlerSite m -> a -> m Encoding

-- | Returns <tt>True</tt> if the client prefers <tt>application/json</tt>
--   as indicated by the <tt>Accept</tt> HTTP header.
acceptsJson :: MonadHandler m => m Bool
yesodRunner :: (ToTypedContent res, Yesod site) => HandlerFor site res -> YesodRunnerEnv site -> Maybe Route site -> Application
yesodRender :: Yesod y => y -> ResolvedApproot -> Route y -> [(Text, Text)] -> Text
class YesodSubDispatch sub master
yesodSubDispatch :: YesodSubDispatch sub master => YesodSubRunnerEnv sub master -> Application

-- | This class is automatically instantiated when you use the template
--   haskell mkYesod function. You should never need to deal with it
--   directly.
class Yesod site => YesodDispatch site
yesodDispatch :: YesodDispatch site => YesodRunnerEnv site -> Application
type LiteWidget = WidgetFor LiteApp
type LiteHandler = HandlerFor LiteApp
newtype LiteApp
LiteApp :: Method -> [Text] -> Maybe LiteHandler TypedContent -> LiteApp
[unLiteApp] :: LiteApp -> Method -> [Text] -> Maybe LiteHandler TypedContent
liteApp :: Writer LiteApp () -> LiteApp
dispatchTo :: ToTypedContent a => LiteHandler a -> Writer LiteApp ()
onMethod :: Method -> Writer LiteApp () -> Writer LiteApp ()
onStatic :: Text -> Writer LiteApp () -> Writer LiteApp ()
withDynamic :: PathPiece p => p -> Writer LiteApp () -> Writer LiteApp ()
withDynamicMulti :: PathMultiPiece ps => ps -> Writer LiteApp () -> Writer LiteApp ()

-- | A type-safe, concise method of creating breadcrumbs for pages. For
--   each resource, you declare the title of the page and the parent
--   resource (if present).
class YesodBreadcrumbs site

-- | Returns the title and the parent resource, if available. If you return
--   a <a>Nothing</a>, then this is considered a top-level page.
breadcrumb :: YesodBreadcrumbs site => Route site -> HandlerFor site (Text, Maybe Route site)

-- | Gets the title of the current page and the hierarchy of parent pages,
--   along with their respective titles.
breadcrumbs :: YesodBreadcrumbs site => HandlerFor site (Text, [(Route site, Text)])

-- | A quasi-quoter to parse a string into a list of <a>Resource</a>s.
--   Checks for overlapping routes, failing if present; use
--   <a>parseRoutesNoCheck</a> to skip the checking. See documentation site
--   for details on syntax.
parseRoutes :: QuasiQuoter
parseRoutesFile :: FilePath -> Q Exp
parseRoutesFileNoCheck :: FilePath -> Q Exp

-- | Same as <a>parseRoutes</a>, but performs no overlap checking.
parseRoutesNoCheck :: QuasiQuoter

-- | Generates URL datatype and site function for the given
--   <a>Resource</a>s. This is used for creating sites, <i>not</i>
--   subsites. See <a>mkYesodSubData</a> and <a>mkYesodSubDispatch</a> for
--   the latter. Use <a>parseRoutes</a> to create the <a>Resource</a>s.
--   
--   Contexts and type variables in the name of the datatype are parsed.
--   For example, a datatype <tt>App a</tt> with typeclass constraint
--   <tt>MyClass a</tt> can be written as <tt>"(MyClass a) =&gt; App
--   a"</tt>.
mkYesod :: String -> [ResourceTree String] -> Q [Dec]

-- | Similar to <a>mkYesod</a>, except contexts and type variables are not
--   parsed. Instead, they are explicitly provided. You can write
--   <tt>(MyClass a) =&gt; App a</tt> with <tt>mkYesodWith
--   [["MyClass","a"]] "App" ["a"] ...</tt>.
mkYesodWith :: [[String]] -> String -> [String] -> [ResourceTree String] -> Q [Dec]

-- | Sometimes, you will want to declare your routes in one file and define
--   your handlers elsewhere. For example, this is the only way to break up
--   a monolithic file into smaller parts. Use this function, paired with
--   <a>mkYesodDispatch</a>, to do just that.
mkYesodData :: String -> [ResourceTree String] -> Q [Dec]
mkYesodSubData :: String -> [ResourceTree String] -> Q [Dec]

-- | See <a>mkYesodData</a>.
mkYesodDispatch :: String -> [ResourceTree String] -> Q [Dec]
mkYesodSubDispatch :: () => [ResourceTree a] -> Q Exp

-- | Convert the given argument into a WAI application, executable with any
--   WAI handler. This function will provide no middlewares; if you want
--   commonly used middlewares, please use <a>toWaiApp</a>.
toWaiAppPlain :: YesodDispatch site => site -> IO Application

-- | Pure low level function to construct WAI application. Usefull when you
--   need not standard way to run your app, or want to embed it inside
--   another app.
toWaiAppYre :: YesodDispatch site => YesodRunnerEnv site -> Application

-- | Same as <a>toWaiAppPlain</a>, but provides a default set of
--   middlewares. This set may change with future releases, but currently
--   covers:
--   
--   <ul>
--   <li>Logging</li>
--   <li>GZIP compression</li>
--   <li>Automatic HEAD method handling</li>
--   <li>Request method override with the _method query string
--   parameter</li>
--   <li>Accept header override with the _accept query string
--   parameter</li>
--   </ul>
toWaiApp :: YesodDispatch site => site -> IO Application

-- | A convenience method to run an application using the Warp webserver on
--   the specified port. Automatically calls <a>toWaiApp</a>. Provides a
--   default set of middlewares. This set may change at any point without a
--   breaking version number. Currently, it includes:
--   
--   If you need more fine-grained control of middlewares, please use
--   <a>toWaiApp</a> directly.
--   
--   Since 1.2.0
warp :: YesodDispatch site => Int -> site -> IO ()

-- | A default set of middlewares.
--   
--   Since 1.2.0
mkDefaultMiddlewares :: Logger -> IO Middleware

-- | All of the default middlewares, excluding logging.
--   
--   Since 1.2.12
defaultMiddlewaresNoLogging :: Middleware

-- | Deprecated synonym for <a>warp</a>.
warpDebug :: YesodDispatch site => Int -> site -> IO ()

-- | Runs your application using default middlewares (i.e., via
--   <a>toWaiApp</a>). It reads port information from the PORT environment
--   variable, as used by tools such as Keter and the FP Complete School of
--   Haskell.
--   
--   Note that the exact behavior of this function may be modified slightly
--   over time to work correctly with external tools, without a change to
--   the type signature.
warpEnv :: YesodDispatch site => site -> IO ()

-- | Default constructor for <a>yreGetMaxExpires</a> field. Low level
--   function for simple manual construction of <a>YesodRunnerEnv</a>.
getGetMaxExpires :: IO IO Text
runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> site -> Logger -> site -> HandlerT site IO a -> m Either ErrorResponse a

-- | Return an <a>Unauthorized</a> value, with the given i18n message.
unauthorizedI :: (MonadHandler m, RenderMessage HandlerSite m msg) => msg -> m AuthResult
yesodVersion :: String

-- | Return the same URL if the user is authorized to see it.
--   
--   Built on top of <a>isAuthorized</a>. This is useful for building page
--   that only contain links to pages the user is allowed to see.
maybeAuthorized :: Yesod site => Route site -> Bool -> HandlerT site IO Maybe Route site
showIntegral :: Integral a => a -> String
readIntegral :: Num a => String -> Maybe a
data Extra
Extra :: Text -> Maybe Text -> Maybe Text -> Extra
[extraCopyright] :: Extra -> Text

-- | Google Analytics
[extraAnalytics] :: Extra -> Maybe Text
[extraStaticRoot] :: Extra -> Maybe Text
development :: Bool
production :: Bool
hledgerorgurl :: Text
manualurl :: Text

-- | The default IP address to listen on. May be overridden with --host.
defhost :: String

-- | The default TCP port to listen on. May be overridden with --port.
defport :: Int
defbaseurl :: String -> Int -> String

-- | The location of static files on your system. This is a file system
--   path. The default value works properly with your scaffolded site.
staticDir :: FilePath

-- | The base URL for your static files. As you can see by the default
--   value, this can simply be "static" appended to your application root.
--   A powerful optimization can be serving static files from a separate
--   domain name. This allows you to use a web server optimized for static
--   files, more easily set expires and cache values, and avoid possibly
--   costly transference of cookies on static files. For more information,
--   please see:
--   <a>http://code.google.com/speed/page-speed/docs/request.html#ServeFromCookielessDomain</a>
--   
--   If you change the resource pattern for StaticR in Foundation.hs, you
--   will have to make a corresponding change here.
--   
--   To see how this value is used, see urlRenderOverride in Foundation.hs
staticRoot :: AppConfig DefaultEnv Extra -> Text

-- | Settings for <a>widgetFile</a>, such as which template languages to
--   support and default Hamlet settings.
widgetFileSettings :: WidgetFileSettings
widgetFile :: String -> Q Exp
parseExtra :: DefaultEnv -> Object -> Parser Extra
staticSite :: IO Static
hledger_css :: StaticRoute
hledger_js :: StaticRoute
fonts_glyphicons_halflings_regular_svg :: StaticRoute
fonts_glyphicons_halflings_regular_woff :: StaticRoute
fonts_glyphicons_halflings_regular_eot :: StaticRoute
fonts_glyphicons_halflings_regular_ttf :: StaticRoute
css_bootstrap_min_css :: StaticRoute
css_bootstrap_theme_css :: StaticRoute
css_bootstrap_css_map :: StaticRoute
css_bootstrap_datepicker_standalone_min_css :: StaticRoute
css_bootstrap_theme_min_css :: StaticRoute
css_bootstrap_theme_css_map :: StaticRoute
css_bootstrap_css :: StaticRoute
js_bootstrap_min_js :: StaticRoute
js_jquery_flot_fillbetween_js :: StaticRoute
js_jquery_flot_symbol_min_js :: StaticRoute
js_jquery_flot_threshold_js :: StaticRoute
js_jquery_flot_pie_min_js :: StaticRoute
js_jquery_flot_selection_min_js :: StaticRoute
js_jquery_flot_crosshair_js :: StaticRoute
js_jquery_flot_stack_js :: StaticRoute
js_jquery_min_js :: StaticRoute
js_jquery_flot_errorbars_min_js :: StaticRoute
js_jquery_flot_categories_min_js :: StaticRoute
js_jquery_cookie_js :: StaticRoute
js_jquery_flot_categories_js :: StaticRoute
js_jquery_flot_time_js :: StaticRoute
js_jquery_js :: StaticRoute
js_jquery_url_js :: StaticRoute
js_excanvas_js :: StaticRoute
js_jquery_flot_canvas_js :: StaticRoute
js_jquery_hotkeys_js :: StaticRoute
js_jquery_flot_pie_js :: StaticRoute
js_jquery_flot_image_js :: StaticRoute
js_jquery_flot_navigate_min_js :: StaticRoute
js_jquery_flot_navigate_js :: StaticRoute
js_jquery_flot_threshold_min_js :: StaticRoute
js_jquery_flot_stack_min_js :: StaticRoute
js_jquery_flot_resize_min_js :: StaticRoute
js_jquery_flot_fillbetween_min_js :: StaticRoute
js_jquery_flot_resize_js :: StaticRoute
js_jquery_flot_image_min_js :: StaticRoute
js_bootstrap_js :: StaticRoute
js_jquery_flot_errorbars_js :: StaticRoute
js_jquery_flot_tooltip_min_js :: StaticRoute
js_jquery_flot_time_min_js :: StaticRoute
js_jquery_flot_tooltip_js :: StaticRoute
js_jquery_flot_js :: StaticRoute
js_jquery_flot_min_js :: StaticRoute
js_typeahead_bundle_js :: StaticRoute
js_typeahead_bundle_min_js :: StaticRoute
js_jquery_flot_canvas_min_js :: StaticRoute
js_jquery_flot_selection_js :: StaticRoute
js_jquery_flot_crosshair_min_js :: StaticRoute
js_excanvas_min_js :: StaticRoute
js_bootstrap_datepicker_min_js :: StaticRoute
js_jquery_flot_symbol_js :: StaticRoute
data Capability
CapView :: Capability
CapAdd :: Capability
CapManage :: Capability

-- | The site argument for your application. This can be a good place to
--   keep settings and values requiring initialization before your
--   application starts running, such as database connections. Every
--   handler will have access to the data present here.
data App
App :: AppConfig DefaultEnv Extra -> Static -> Manager -> WebOpts -> IORef Journal -> App
[settings] :: App -> AppConfig DefaultEnv Extra

-- | Settings for static file serving.
[getStatic] :: App -> Static
[httpManager] :: App -> Manager
[appOpts] :: App -> WebOpts
[appJournal] :: App -> IORef Journal

-- | A bundle of data useful for hledger-web request handlers and
--   templates.
data ViewData
VD :: WebOpts -> Day -> Journal -> Text -> Query -> [QueryOpt] -> [Capability] -> ViewData

-- | the command-line options at startup
[opts] :: ViewData -> WebOpts

-- | today's date (for queries containing relative dates)
[today] :: ViewData -> Day

-- | the up-to-date parsed unfiltered journal
[j] :: ViewData -> Journal

-- | the current q parameter, the main query expression
[q] :: ViewData -> Text

-- | a query parsed from the q parameter
[m] :: ViewData -> Query

-- | query options parsed from the q parameter
[qopts] :: ViewData -> [QueryOpt]

-- | capabilities enabled for this request
[caps] :: ViewData -> [Capability]
type Form x = Html -> MForm (HandlerFor App) (FormResult x, Widget)

-- | A convenience alias.
type AppRoute = Route App
type Widget = WidgetFor App ()
type Handler = HandlerFor App
resourcesApp :: [ResourceTree String]

-- | Gather data used by handlers and templates in the current request.
getViewData :: Handler ViewData

-- | Find out if the sidebar should be visible. Show it, unless there is a
--   showsidebar cookie set to "0", or a ?sidebar=0 query parameter.
shouldShowSidebar :: Handler Bool

-- | Update our copy of the journal if the file changed. If there is an
--   error while reloading, keep the old one and return the error, and set
--   a ui message.
getCurrentJournal :: IORef Journal -> CliOpts -> Day -> Handler (Journal, Maybe String)

module Hledger.Web.Handler.UploadR
getUploadR :: FilePath -> Handler ()
postUploadR :: FilePath -> Handler ()


-- | /register handlers.
module Hledger.Web.Handler.RegisterR

-- | The main journal/account register view, with accounts sidebar.
getRegisterR :: Handler Html

-- | Generate javascript/html for a register balance line chart based on
--   the provided <a>TransactionsReportItem</a>s.
registerChartHtml :: [(CommoditySymbol, (String, [TransactionsReportItem]))] -> HtmlUrl AppRoute
dayToJsTimestamp :: Day -> Integer


-- | /journal handlers.
module Hledger.Web.Handler.JournalR

-- | The formatted journal view, with sidebar.
getJournalR :: Handler Html

module Hledger.Web.Handler.EditR
getEditR :: FilePath -> Handler ()
postEditR :: FilePath -> Handler ()

module Hledger.Web.Handler.Common
getDownloadR :: FilePath -> Handler TypedContent
getFaviconR :: MonadHandler m => m ()
getManageR :: Handler Html
getRobotsR :: MonadHandler m => m ()
getRootR :: Handler Html

module Hledger.Web.Handler.AddR
getAddR :: Handler ()
postAddR :: Handler ()

module Hledger.Web.Application
makeApplication :: WebOpts -> Journal -> AppConfig DefaultEnv Extra -> IO Application
makeFoundation :: AppConfig DefaultEnv Extra -> WebOpts -> IO App
instance Yesod.Core.Class.Dispatch.YesodDispatch Hledger.Web.Foundation.App


-- | hledger-web - a hledger add-on providing a web interface. Copyright
--   (c) 2007-2012 Simon Michael <a>simon@joyful.com</a> Released under GPL
--   version 3 or later.
module Hledger.Web.Main
hledgerWebMain :: IO ()
hledgerWebDev :: IO (Int, Application)
runWith :: WebOpts -> IO ()

-- | A version of withJournalDo specialised for hledger-web. Disallows the
--   special - file to avoid some bug, takes WebOpts rather than CliOpts.
withJournalDoWeb :: WebOpts -> (WebOpts -> Journal -> IO a) -> IO a

-- | The web command.
web :: WebOpts -> Journal -> IO ()


-- | Re-export the modules of the hledger-web program.
module Hledger.Web
tests_Hledger_Web :: Test
