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


-- | Creation of type-safe, RESTful web applications.
--   
--   Yesod is a framework designed to foster creation of RESTful web
--   application that have strong compile-time guarantees of correctness.
--   It also affords space efficient code and portability to many
--   deployment backends, from CGI to stand-alone serving.
--   
--   The Yesod documentation site <a>http://www.yesodweb.com/</a> has much
--   more information, tutorials and information on some of the supporting
--   packages, like Hamlet and Persistent.
@package yesod-core
@version 1.1.8.3


-- | This module has moved to <a>Text.Shakespeare.I18N</a>
module Yesod.Message

module Yesod.Content
data Content

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

-- | Zero-length enumerator.
emptyContent :: Content

-- | 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
type ContentType = ByteString
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

-- | Prevents a response body from being fully evaluated before sending the
--   request.
--   
--   Since 1.1.0
newtype DontFullyEvaluate a
DontFullyEvaluate :: a -> DontFullyEvaluate a

-- | A function which gives targetted representations of content based on
--   the content-types the user accepts.
type ChooseRep = [ContentType] -> IO (ContentType, Content)

-- | Any type which can be converted to representations.
class HasReps a
chooseRep :: HasReps a => a -> ChooseRep

-- | A helper method for generating <a>HasReps</a> instances.
--   
--   This function should be given a list of pairs of content type and
--   conversion functions. If none of the content types match, the first
--   pair is used.
defChooseRep :: [(ContentType, a -> IO Content)] -> a -> ChooseRep
newtype RepHtml
RepHtml :: Content -> RepHtml
newtype RepJson
RepJson :: Content -> RepJson
data RepHtmlJson
RepHtmlJson :: Content -> Content -> RepHtmlJson
newtype RepPlain
RepPlain :: Content -> RepPlain
newtype RepXml
RepXml :: Content -> RepXml

-- | 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
instance ToContent Value
instance ToContent a => ToContent (DontFullyEvaluate a)
instance HasReps a => HasReps (DontFullyEvaluate a)
instance HasReps RepXml
instance HasReps RepPlain
instance HasReps RepHtmlJson
instance HasReps RepJson
instance HasReps RepHtml
instance HasReps [(ContentType, Content)]
instance HasReps (ContentType, Content)
instance HasReps ()
instance HasReps ChooseRep
instance ToContent Html
instance ToContent String
instance ToContent Text
instance ToContent Text
instance ToContent ByteString
instance ToContent ByteString
instance ToContent Builder
instance IsString Content


-- | WARNING: This module exposes internal interfaces solely for the
--   purpose of facilitating cabal-driven testing of said interfaces. This
--   module is NOT part of the public Yesod API and should NOT be imported
--   by library users.
module Yesod.Internal.TestApi

-- | Generate a random String of alphanumerical characters (a-z, A-Z, and
--   0-9) of the given length using the given random number generator.
randomString :: RandomGen g => Int -> g -> String
parseWaiRequest' :: RandomGen g => Request -> [(Text, ByteString)] -> Bool -> Word64 -> Word64 -> g -> Request

module Yesod.Handler
class YesodSubRoute s y
fromSubRoute :: YesodSubRoute s y => s -> y -> Route s -> Route y

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

-- | Get the master site appliation argument.
getYesod :: GHandler sub master master

-- | Get the sub application argument.
getYesodSub :: GHandler sub master sub

-- | Get the URL rendering function.
getUrlRender :: GHandler sub master (Route master -> Text)

-- | The URL rendering function with query-string parameters.
getUrlRenderParams :: GHandler sub master (Route master -> [(Text, 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 :: GHandler sub master (Maybe (Route sub))

-- | Get the function to promote a route for a subsite to a route for the
--   master site.
getRouteToMaster :: GHandler sub master (Route sub -> Route master)
getRequest :: GHandler s m Request

-- | Get the request's <a>Request</a> value.
waiRequest :: GHandler sub master Request
runRequestBody :: GHandler s m RequestBodyContents

-- | Some value which can be turned into a URL for redirects.
class RedirectUrl master a
toTextUrl :: RedirectUrl master a => a -> GHandler sub master Text

-- | 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 :: RedirectUrl master url => url -> GHandler sub master a

-- | Redirect to the given URL with the specified status code.
redirectWith :: RedirectUrl master url => Status -> url -> GHandler sub master a

-- | 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 :: RedirectUrl master url => url -> GHandler sub master a

-- | Return a 404 not found page. Also denotes no handler available.
notFound :: GHandler sub master a

-- | Return a 405 method not supported page.
badMethod :: GHandler sub master a

-- | Return a 403 permission denied page.
permissionDenied :: Text -> GHandler sub master a

-- | Return a 403 permission denied page.
permissionDeniedI :: RenderMessage master msg => msg -> GHandler sub master a

-- | Return a 400 invalid arguments page.
invalidArgs :: [Text] -> GHandler sub master a

-- | Return a 400 invalid arguments page.
invalidArgsI :: RenderMessage y msg => [msg] -> GHandler s y a

-- | 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 :: ContentType -> FilePath -> GHandler sub master a

-- | Same as <a>sendFile</a>, but only sends part of a file.
sendFilePart :: ContentType -> FilePath -> Integer -> Integer -> GHandler sub master a

-- | Bypass remaining handler code and output the given content with a 200
--   status code.
sendResponse :: HasReps c => c -> GHandler sub master a

-- | Bypass remaining handler code and output the given content with the
--   given status code.
sendResponseStatus :: HasReps c => Status -> c -> GHandler s m a

-- | Send a 201 <a>Created</a> response with the given route as the
--   Location response header.
sendResponseCreated :: Route m -> GHandler s 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 :: Response -> GHandler s m b

-- | Set the cookie on the client.
setCookie :: SetCookie -> GHandler sub master ()

-- | Helper function for setCookieExpires value
getExpires :: Int -> IO 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 :: Text -> Text -> GHandler sub master ()

-- | 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.
setHeader :: Text -> Text -> GHandler sub master ()

-- | Set the language in the user session. Will show up in
--   <tt>languages</tt> on the next request.
setLanguage :: Text -> GHandler sub master ()

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

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

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

-- | Set an Expires header to the given date.
expiresAt :: UTCTime -> GHandler s m ()
type SessionMap = Map Text ByteString

-- | Lookup for session data.
lookupSession :: Text -> GHandler s m (Maybe Text)

-- | Lookup for session data in binary format.
lookupSessionBS :: Text -> GHandler s m (Maybe ByteString)

-- | Get all session variables.
getSession :: GHandler sub master SessionMap

-- | 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 :: Text -> Text -> GHandler sub master ()

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

-- | Unsets a session variable. See <a>setSession</a>.
deleteSession :: Text -> GHandler sub master ()

-- | Clear all session variables.
--   
--   Since: 1.0.1
clearSession :: GHandler sub master ()

-- | 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 :: RedirectUrl master url => url -> GHandler sub master ()

-- | 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 :: GHandler sub master ()

-- | Sets the ultimate destination to the referer request header, if
--   present.
--   
--   This function will not overwrite an existing ultdest.
setUltDestReferer :: GHandler sub master ()

-- | 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 master url => url -> GHandler sub master a

-- | Remove a previously set ultimate destination. See <a>setUltDest</a>.
clearUltDest :: GHandler sub master ()

-- | Sets a message in the user's session.
--   
--   See <a>getMessage</a>.
setMessage :: Html -> GHandler sub master ()

-- | Sets a message in the user's session.
--   
--   See <a>getMessage</a>.
setMessageI :: RenderMessage y msg => msg -> GHandler sub y ()

-- | Gets the message in the user's session, if available, and then clears
--   the variable.
--   
--   See <a>setMessage</a>.
getMessage :: GHandler sub master (Maybe Html)

-- | Converts the given Hamlet template into <a>Content</a>, which can be
--   used in a Yesod <tt>Response</tt>.
hamletToContent :: HtmlUrl (Route master) -> GHandler sub master Content

-- | Wraps the <a>Content</a> generated by <a>hamletToContent</a> in a
--   <a>RepHtml</a>.
hamletToRepHtml :: HtmlUrl (Route master) -> GHandler sub master RepHtml

-- | Get a unique identifier.
newIdent :: GHandler sub master Text

-- | The standard <tt>MonadTrans</tt> class only allows lifting for monad
--   transformers. While <tt>GHandler</tt> and <tt>GWidget</tt> should
--   allow lifting, their types do not express that they actually are
--   transformers. This replacement class accounts for this.
class MonadLift base m | m -> base
lift :: MonadLift base m => base a -> m a

-- | Returns a function that runs <a>GHandler</a> actions inside
--   <tt>IO</tt>.
--   
--   Sometimes you want to run an inner <a>GHandler</a> action outside the
--   control flow of an HTTP request (on the outer <a>GHandler</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 <a>GHandler</a> actions (see <tt>yesod-eventsource</tt>).
--   
--   Most of the environment from the outer <a>GHandler</a> is preserved on
--   the inner <a>GHandler</a>, 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 <a>CacheKey</a>).</li>
--   </ul>
--   
--   Changes to the response made inside the inner <a>GHandler</a> are
--   ignored (e.g., session variables, cookies, response headers). This
--   allows the inner <a>GHandler</a> to outlive the outer <a>GHandler</a>
--   (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 => GHandler sub master (GHandler sub master a -> m a)
getMessageRender :: RenderMessage master message => GHandler s master (message -> Text)
data CacheKey a

-- | Generate a new <a>CacheKey</a>. Be sure to give a full type signature.
mkCacheKey :: Q Exp
cacheLookup :: CacheKey a -> GHandler sub master (Maybe a)
cacheInsert :: CacheKey a -> a -> GHandler sub master ()
cacheDelete :: CacheKey a -> GHandler sub master ()

-- | Function used internally by Yesod in the process of converting a
--   <a>GHandler</a> into an <a>Application</a>. Should not be needed by
--   users.
runHandler :: HasReps c => GHandler sub master c -> (Route master -> [(Text, Text)] -> Text) -> Maybe (Route sub) -> (Route sub -> Route master) -> master -> sub -> (Word64 -> FileUpload) -> (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> YesodApp

-- | An extension of the basic WAI <a>Application</a> datatype to provide
--   extra features needed by Yesod. Users should never need to use this
--   directly, as the <a>GHandler</a> monad and template haskell code
--   should hide it away.
newtype YesodApp
YesodApp :: ((ErrorResponse -> YesodApp) -> Request -> [ContentType] -> SessionMap -> ResourceT IO YesodAppResult) -> YesodApp
unYesodApp :: YesodApp -> (ErrorResponse -> YesodApp) -> Request -> [ContentType] -> SessionMap -> ResourceT IO YesodAppResult
runSubsiteGetter :: SubsiteGetter g m s => g -> m s

-- | Used internally for promoting subsite handler functions to master site
--   handler functions. Should not be needed by users.
toMasterHandler :: (Route sub -> Route master) -> (master -> sub) -> Route sub -> GHandler sub master a -> GHandler sub' master a

-- | FIXME do we need this?
toMasterHandlerDyn :: (Route sub -> Route master) -> GHandler sub' master sub -> Route sub -> GHandler sub master a -> GHandler sub' master a
toMasterHandlerMaybe :: (Route sub -> Route master) -> (master -> sub) -> Maybe (Route sub) -> GHandler sub master a -> GHandler sub' master a
localNoCurrent :: GHandler s m a -> GHandler s m a
data HandlerData sub master

-- | Responses to indicate some form of an error occurred. These are
--   different from <tt>SpecialResponse</tt> in that they allow for custom
--   error pages.
data ErrorResponse
NotFound :: ErrorResponse
InternalError :: Text -> ErrorResponse
InvalidArgs :: [Text] -> ErrorResponse
PermissionDenied :: Text -> ErrorResponse
BadMethod :: Method -> ErrorResponse
data YesodAppResult
YARWai :: Response -> YesodAppResult
YARPlain :: Status -> [Header] -> ContentType -> Content -> SessionMap -> YesodAppResult
handlerToYAR :: (HasReps a, HasReps b) => master -> sub -> (Word64 -> FileUpload) -> (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> (Route sub -> Route master) -> (Route master -> [(Text, Text)] -> Text) -> (ErrorResponse -> GHandler sub master a) -> Request -> Maybe (Route sub) -> SessionMap -> GHandler sub master b -> ResourceT IO YesodAppResult
yarToResponse :: YesodAppResult -> [(CI ByteString, ByteString)] -> Response

-- | Convert Header to a key/value pair.
headerToPair :: Header -> (CI ByteString, ByteString)
instance Exception e => Failure e (GHandler sub master)
instance MonadLogger (GHandler sub master)
instance MonadResource (GHandler sub master)
instance MonadThrow (GHandler sub master)
instance MonadUnsafeIO (GHandler sub master)
instance MonadBaseControl IO (GHandler sub master)
instance MonadBase IO (GHandler sub master)
instance MonadIO (GHandler sub master)
instance Monad (GHandler sub master)
instance Applicative (GHandler sub master)
instance Functor (GHandler sub master)
instance MonadLift (ResourceT IO) (GHandler sub master)
instance (Monad m, MonadTrans t) => MonadLift m (t m)
instance (key ~ Text, val ~ Text) => RedirectUrl master (Route master, [(key, val)])
instance RedirectUrl master (Route master)
instance RedirectUrl master String
instance RedirectUrl master Text
instance (anySub ~ anySub', master ~ master') => SubsiteGetter (GHandler anySub master sub) (GHandler anySub' master') sub
instance master ~ master' => SubsiteGetter (master -> sub) (GHandler anySub master') sub


-- | Provides a parsed version of the raw <a>Request</a> data.
module Yesod.Request

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

-- | The parsed request information.
data Request
Request :: [(Text, Text)] -> [(Text, Text)] -> Request -> [Text] -> Maybe Text -> Word64 -> Request
reqGetParams :: Request -> [(Text, Text)]
reqCookies :: Request -> [(Text, Text)]
reqWaiRequest :: Request -> Request

-- | Languages which the client supports.
reqLangs :: Request -> [Text]

-- | A random, session-specific token used to prevent CSRF attacks.
reqToken :: Request -> Maybe Text

-- | Size of the request body.
--   
--   Note: in the presence of chunked request bodies, this value will be 0,
--   even though data is available.
reqBodySize :: Request -> Word64
data FileInfo
fileName :: FileInfo -> Text
fileContentType :: FileInfo -> Text
fileSource :: FileInfo -> Source (ResourceT IO) ByteString
fileMove :: FileInfo -> FilePath -> IO ()

-- | Get the list of supported languages supplied by the user.
--   
--   Languages are determined based on the following three (in descending
--   order of preference):
--   
--   <ul>
--   <li>The _LANG get parameter.</li>
--   <li>The _LANG cookie.</li>
--   <li>The _LANG user session variable.</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 :: GHandler s m [Text]

-- | Lookup for GET parameters.
lookupGetParam :: Text -> GHandler s m (Maybe Text)
lookupPostParam :: Text -> GHandler s m (Maybe Text)

-- | Lookup for cookie data.
lookupCookie :: Text -> GHandler s m (Maybe Text)

-- | Lookup for POSTed files.
lookupFile :: Text -> GHandler s m (Maybe FileInfo)

-- | Lookup for GET parameters.
lookupGetParams :: Text -> GHandler s m [Text]

-- | Lookup for POST parameters.
lookupPostParams :: Text -> GHandler s m [Text]

-- | Lookup for cookie data.
lookupCookies :: Text -> GHandler s m [Text]

-- | Lookup for POSTed files.
lookupFiles :: Text -> GHandler s m [FileInfo]


-- | Widgets combine HTML with JS and CSS dependencies with a unique
--   identifier generator, allowing you to create truly modular HTML
--   components.
module Yesod.Widget

-- | 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 GWidget sub master a

-- | 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
whamlet :: QuasiQuoter
whamletFile :: FilePath -> Q Exp

-- | Wraps the <tt>Content</tt> generated by <tt>hamletToContent</tt> in a
--   <a>RepHtml</a>.
ihamletToRepHtml :: RenderMessage master message => HtmlUrlI18n message (Route master) -> GHandler sub master RepHtml
class ToWidget sub master a
toWidget :: ToWidget sub master a => a -> GWidget sub master ()
class ToWidgetHead sub master a
toWidgetHead :: ToWidgetHead sub master a => a -> GWidget sub master ()
class ToWidgetBody sub master a
toWidgetBody :: ToWidgetBody sub master a => a -> GWidget sub master ()

-- | Set the page title. Calling <a>setTitle</a> multiple times overrides
--   previously set values.
setTitle :: Html -> GWidget sub master ()

-- | Set the page title. Calling <a>setTitle</a> multiple times overrides
--   previously set values.
setTitleI :: RenderMessage master msg => msg -> GWidget sub master ()

-- | Add a <tt>Hamlet</tt> to the head tag.

-- | <i>Deprecated: Use toWidgetHead instead </i>
addHamletHead :: HtmlUrl (Route master) -> GWidget sub master ()

-- | Add a <a>Html</a> to the head tag.

-- | <i>Deprecated: Use toWidgetHead instead </i>
addHtmlHead :: Html -> GWidget sub master ()

-- | Add a <tt>Hamlet</tt> to the body tag.

-- | <i>Deprecated: Use toWidget instead </i>
addHamlet :: HtmlUrl (Route master) -> GWidget sub master ()

-- | Add a <a>Html</a> to the body tag.

-- | <i>Deprecated: Use toWidget instead </i>
addHtml :: Html -> GWidget sub master ()

-- | Add another widget. This is defined as <a>id</a>, by can help with
--   types, and makes widget blocks look more consistent.

-- | <i>Deprecated: addWidget can be omitted </i>
addWidget :: GWidget sub master () -> GWidget sub master ()
addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master a

-- | Add some raw CSS to the style tag. Applies to all media types.

-- | <i>Deprecated: Use toWidget instead </i>
addCassius :: CssUrl (Route master) -> GWidget sub master ()

-- | Add some raw CSS to the style tag, for a specific media type.
addCassiusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()

-- | Identical to <a>addCassius</a>.

-- | <i>Deprecated: Use toWidget instead </i>
addLucius :: CssUrl (Route master) -> GWidget sub master ()

-- | Identical to <a>addCassiusMedia</a>.
addLuciusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()

-- | Link to the specified local stylesheet.
addStylesheet :: Route master -> GWidget sub master ()

-- | Link to the specified local stylesheet.
addStylesheetAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()

-- | Link to the specified remote stylesheet.
addStylesheetRemote :: Text -> GWidget sub master ()

-- | Link to the specified remote stylesheet.
addStylesheetRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()
addStylesheetEither :: Either (Route master) Text -> GWidget sub master ()

-- | 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

-- | Include raw Javascript in the page's script tag.

-- | <i>Deprecated: Use toWidget instead </i>
addJulius :: JavascriptUrl (Route master) -> GWidget sub master ()

-- | Add a new script tag to the body with the contents of this
--   <tt>Julius</tt> template.

-- | <i>Deprecated: Use toWidgetBody instead </i>
addJuliusBody :: JavascriptUrl (Route master) -> GWidget sub master ()

-- | Link to the specified local script.
addScript :: Route master -> GWidget sub master ()

-- | Link to the specified local script.
addScriptAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()

-- | Link to the specified remote script.
addScriptRemote :: Text -> GWidget sub master ()

-- | Link to the specified remote script.
addScriptRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()
addScriptEither :: Either (Route master) Text -> GWidget sub master ()
unGWidget :: GWidget sub master a -> GHandler sub master (a, GWData (Route master))
whamletFileWithSettings :: HamletSettings -> FilePath -> Q Exp
instance MonadLogger (GWidget sub master)
instance MonadResource (GWidget sub master)
instance MonadThrow (GWidget sub master)
instance MonadUnsafeIO (GWidget sub master)
instance MonadBaseControl IO (GWidget sub master)
instance MonadBase IO (GWidget sub master)
instance MonadIO (GWidget sub master)
instance Monad (GWidget sub master)
instance Applicative (GWidget sub master)
instance Functor (GWidget sub master)
instance MonadLift (GHandler sub master) (GWidget sub master)
instance ToWidgetHead sub master Html
instance render ~ RY master => ToWidgetHead sub master (render -> Javascript)
instance render ~ RY master => ToWidgetHead sub master (render -> CssBuilder)
instance render ~ RY master => ToWidgetHead sub master (render -> Css)
instance render ~ RY master => ToWidgetHead sub master (render -> Html)
instance ToWidgetBody sub master Html
instance render ~ RY master => ToWidgetBody sub master (render -> Javascript)
instance render ~ RY master => ToWidgetBody sub master (render -> Html)
instance ToWidget sub master Html
instance (sub' ~ sub, master' ~ master) => ToWidget sub' master' (GWidget sub master ())
instance render ~ RY master => ToWidget sub master (render -> Javascript)
instance render ~ RY master => ToWidget sub master (render -> CssBuilder)
instance render ~ RY master => ToWidget sub master (render -> Css)
instance render ~ RY master => ToWidget sub master (render -> Html)
instance a ~ () => Monoid (GWidget sub master a)

module Yesod.Dispatch

-- | 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

-- | Same as <a>parseRoutes</a>, but performs no overlap checking.
parseRoutesNoCheck :: QuasiQuoter
parseRoutesFile :: FilePath -> Q Exp
parseRoutesFileNoCheck :: FilePath -> Q Exp

-- | 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>mkYesodSub</a> for the latter. Use <a>parseRoutes</a>
--   to create the <a>Resource</a>s.
mkYesod :: String -> [ResourceTree String] -> Q [Dec]

-- | Generates URL datatype and site function for the given
--   <a>Resource</a>s. This is used for creating subsites, <i>not</i>
--   sites. See <a>mkYesod</a> for the latter. Use <a>parseRoutes</a> to
--   create the <a>Resource</a>s. In general, a subsite is not executable
--   by itself, but instead provides functionality to be embedded in other
--   sites.
mkYesodSub :: String -> Cxt -> [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 -> Cxt -> [ResourceTree String] -> Q [Dec]

-- | See <a>mkYesodData</a>.
mkYesodDispatch :: String -> [ResourceTree String] -> Q [Dec]
mkYesodSubDispatch :: String -> Cxt -> [ResourceTree String] -> Q [Dec]

-- | If the generation of <tt><a>YesodDispatch</a></tt> instance require
--   finer control of the types, contexts etc. using this combinator. You
--   will hardly need this generality. However, in certain situations, like
--   when writing library/plugin for yesod, this combinator becomes handy.
mkDispatchInstance :: CxtQ -> TypeQ -> TypeQ -> [ResourceTree a] -> DecsQ
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]
type Texts = [Text]

-- | Convert the given argument into a WAI application, executable with any
--   WAI handler. This is the same as <a>toWaiAppPlain</a>, except it
--   includes two middlewares: GZIP compression and autohead. This is the
--   recommended approach for most users.
toWaiApp :: (Yesod master, YesodDispatch master master) => master -> IO Application

-- | Convert the given argument into a WAI application, executable with any
--   WAI handler. This differs from <a>toWaiApp</a> in that it uses no
--   middlewares.
toWaiAppPlain :: (Yesod master, YesodDispatch master master) => master -> IO Application

-- | Wrap up a normal WAI application as a Yesod subsite.
newtype WaiSubsite
WaiSubsite :: Application -> WaiSubsite
runWaiSubsite :: WaiSubsite -> Application
instance Show (Route WaiSubsite)
instance Eq (Route WaiSubsite)
instance Read (Route WaiSubsite)
instance Ord (Route WaiSubsite)
instance YesodDispatch WaiSubsite master
instance RenderRoute WaiSubsite

module Yesod.Core

-- | Define settings for a Yesod applications. All methods have intelligent
--   defaults, and therefore no implementation is required.
class RenderRoute a => Yesod a where approot = ApprootRelative errorHandler = defaultErrorHandler defaultLayout w = do { p <- widgetToPageContent w; mmsg <- getMessage; hamletToRepHtml (\ _render_aKqN -> do { id ((preEscapedText . pack) "<!DOCTYPE html>\ \<html><head><title>"); id (toHtml (pageTitle p)); id ((preEscapedText . pack) "</title>"); asHtmlUrl (pageHead p) _render_aKqN; id ((preEscapedText . pack) "</head><body>"); maybeH mmsg (\ msg_aKqO -> do { id ((preEscapedText . pack) "<p class=\"message\">"); id (toHtml msg_aKqO); id ((preEscapedText . pack) "</p>") }) Nothing; asHtmlUrl (pageBody p) _render_aKqN; id ((preEscapedText . pack) "</body></html>") }) } urlRenderOverride _ _ = Nothing isAuthorized _ _ = return Authorized isWriteRequest _ = do { wai <- waiRequest; return $ requestMethod wai `notElem` ["GET", "HEAD", "OPTIONS", "TRACE"] } authRoute _ = Nothing cleanPath _ s = if corrected == s then Right $ map dropDash s else Left corrected where corrected = filter (not . null) s dropDash t | all (== '-') t = drop 1 t | otherwise = t joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs where pieces = if null pieces' then [""] else map addDash pieces' qs = map (encodeUtf8 *** go) qs' go "" = Nothing go x = Just $ encodeUtf8 x addDash t | all (== '-') t = cons '-' t | otherwise = t addStaticContent _ _ _ = return Nothing cookiePath _ = "/" cookieDomain _ = Nothing maximumContentLength _ _ = 2 * 1024 * 1024 getLogger _ = mkLogger True stdout messageLogger a logger loc = messageLoggerSource a logger loc "" messageLoggerSource a logger loc source level msg = if shouldLog a source level then formatLogMessage (loggerDate logger) loc source level msg >>= loggerPutStr logger else return () logLevel _ = LevelInfo gzipSettings _ = def jsLoader _ = BottomOfBody makeSessionBackend _ = fmap Just defaultClientSessionBackend fileUpload _ size | size > 50000 = FileUploadDisk tempFileBackEnd | otherwise = FileUploadMemory lbsBackEnd shouldLog a _ level = level >= logLevel a yesodMiddleware handler = do { setHeader "Vary" "Accept, Accept-Language"; handler }
approot :: Yesod a => Approot a
errorHandler :: Yesod a => ErrorResponse -> GHandler sub a ChooseRep
defaultLayout :: Yesod a => GWidget sub a () -> GHandler sub a RepHtml
urlRenderOverride :: Yesod a => a -> Route a -> Maybe Builder
isAuthorized :: Yesod a => Route a -> Bool -> GHandler s a AuthResult
isWriteRequest :: Yesod a => Route a -> GHandler s a Bool
authRoute :: Yesod a => a -> Maybe (Route a)
cleanPath :: Yesod a => a -> [Text] -> Either [Text] [Text]
joinPath :: Yesod a => a -> Text -> [Text] -> [(Text, Text)] -> Builder
addStaticContent :: Yesod a => Text -> Text -> ByteString -> GHandler sub a (Maybe (Either Text (Route a, [(Text, Text)])))
cookiePath :: Yesod a => a -> ByteString
cookieDomain :: Yesod a => a -> Maybe ByteString
maximumContentLength :: Yesod a => a -> Maybe (Route a) -> Word64
getLogger :: Yesod a => a -> IO Logger
messageLogger :: Yesod a => a -> Logger -> Loc -> LogLevel -> LogStr -> IO ()
messageLoggerSource :: Yesod a => a -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
logLevel :: Yesod a => a -> LogLevel
gzipSettings :: Yesod a => a -> GzipSettings
jsLoader :: Yesod a => a -> ScriptLoadPosition a
makeSessionBackend :: Yesod a => a -> IO (Maybe (SessionBackend a))
fileUpload :: Yesod a => a -> Word64 -> FileUpload
shouldLog :: Yesod a => a -> LogSource -> LogLevel -> Bool
yesodMiddleware :: Yesod a => GHandler sub a res -> GHandler sub a res

-- | This class is automatically instantiated when you use the template
--   haskell mkYesod function. You should never need to deal with it
--   directly.
class YesodDispatch sub master where yesodRunner = defaultYesodRunner
yesodDispatch :: (YesodDispatch sub master, Yesod master) => Logger -> master -> sub -> (Route sub -> Route master) -> (Maybe (SessionBackend master) -> Application) -> (Route sub -> Maybe (SessionBackend master) -> Application) -> Text -> [Text] -> Maybe (SessionBackend master) -> Application
yesodRunner :: (YesodDispatch sub master, Yesod master) => Logger -> GHandler sub master ChooseRep -> master -> sub -> Maybe (Route sub) -> (Route sub -> Route master) -> Maybe (SessionBackend master) -> Application
class Eq (Route a) => RenderRoute a where data family Route a1
renderRoute :: RenderRoute a => Route a -> ([Text], [(Text, Text)])

-- | 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 y
breadcrumb :: YesodBreadcrumbs y => Route y -> GHandler sub y (Text, Maybe (Route y))

-- | Gets the title of the current page and the hierarchy of parent pages,
--   along with their respective titles.
breadcrumbs :: YesodBreadcrumbs y => GHandler sub y (Text, [(Route y, Text)])

-- | 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 :: (BackEnd FilePath) -> FileUpload
FileUploadSource :: (BackEnd (Source (ResourceT IO) ByteString)) -> FileUpload

-- | 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 a => Route a -> Bool -> GHandler s a (Maybe (Route a))

-- | Convert a widget to a <a>PageContent</a>.
widgetToPageContent :: (Eq (Route master), Yesod master) => GWidget sub master () -> GHandler sub master (PageContent (Route master))

-- | The default error handler for <a>errorHandler</a>.
defaultErrorHandler :: Yesod y => ErrorResponse -> GHandler sub y ChooseRep
data AuthResult
Authorized :: AuthResult
AuthenticationRequired :: AuthResult
Unauthorized :: Text -> AuthResult

-- | Return an <a>Unauthorized</a> value, with the given i18n message.
unauthorizedI :: RenderMessage master msg => msg -> GHandler sub master AuthResult
data LogLevel :: *
LevelDebug :: LogLevel
LevelInfo :: LogLevel
LevelWarn :: LogLevel
LevelError :: LogLevel
LevelOther :: Text -> LogLevel

-- | 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

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

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

-- | See <a>logDebug</a>
logError :: 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

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

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

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

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

-- | 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>
--   $logOther "SomeSource" "My new level" "This is a log message"
--   </pre>
logOtherS :: Q Exp
newtype SessionBackend master
SessionBackend :: (master -> Request -> UTCTime -> IO (BackendSession, SaveSession)) -> SessionBackend master

-- | Return the session data and a function to save the session
sbLoadSession :: SessionBackend master -> master -> Request -> UTCTime -> IO (BackendSession, SaveSession)
defaultClientSessionBackend :: Yesod master => IO (SessionBackend master)

-- | <i>Deprecated: Please use clientSessionBackend2, which is more
--   efficient. </i>
clientSessionBackend :: Yesod master => Key -> Int -> SessionBackend master
clientSessionBackend2 :: Yesod master => Key -> IO ClientSessionDateCache -> SessionBackend master
clientSessionDateCacher :: NominalDiffTime -> IO (IO ClientSessionDateCache, IO ())

-- | <i>Deprecated: Please use loadClientSession2, which is more efficient.
--   </i>
loadClientSession :: Yesod master => Key -> Int -> ByteString -> master -> Request -> UTCTime -> IO (BackendSession, SaveSession)

-- | Headers to be added to a <tt>Result</tt>.
data Header
AddCookie :: SetCookie -> Header
DeleteCookie :: ByteString -> ByteString -> Header
Header :: ByteString -> ByteString -> Header
type BackendSession = [(Text, ByteString)]

-- | For use with setting <a>jsLoader</a> to <a>BottomOfHeadAsync</a>
loadJsYepnope :: Yesod master => Either Text (Route master) -> [Text] -> Maybe (HtmlUrl (Route master)) -> (HtmlUrl (Route master))
data ScriptLoadPosition master
BottomOfBody :: ScriptLoadPosition master
BottomOfHeadBlocking :: ScriptLoadPosition master
BottomOfHeadAsync :: (BottomOfHeadAsync master) -> ScriptLoadPosition master
type BottomOfHeadAsync master = [Text] -> Maybe (HtmlUrl (Route master)) -> (HtmlUrl (Route master))
yesodVersion :: String
yesodRender :: Yesod y => y -> ResolvedApproot -> Route y -> [(Text, Text)] -> Text

-- | Run a <a>GHandler</a> completely outside of Yesod. This function comes
--   with many caveats and you shouldn't use it unless you fully understand
--   what it's doing and how it works.
--   
--   As of now, there's only one reason to use this function at all: in
--   order to run unit tests of functions inside <a>GHandler</a> but that
--   aren't easily testable with a full HTTP request. Even so, it's better
--   to use <tt>wai-test</tt> or <tt>yesod-test</tt> instead of using this
--   function.
--   
--   This function will create a fake HTTP request (both <tt>wai</tt>'s
--   <a>Request</a> and <tt>yesod</tt>'s <a>Request</a>) and feed it to the
--   <tt>GHandler</tt>. The only useful information the <tt>GHandler</tt>
--   may get from the request is the session map, which you must supply as
--   argument to <tt>runFakeHandler</tt>. All other fields contain fake
--   information, which means that they can be accessed but won't have any
--   useful information. The response of the <tt>GHandler</tt> is
--   completely ignored, including changes to the session, cookies or
--   headers. We only return you the <tt>GHandler</tt>'s return value.

-- | <i>Warning: Usually you should *not* use runFakeHandler unless you
--   really understand how it works and why you need it. </i>
runFakeHandler :: (Yesod master, MonadIO m) => SessionMap -> (master -> Logger) -> master -> GHandler master master a -> m (Either ErrorResponse a)
