Safe Haskell | None |
---|---|
Language | Haskell98 |
- class RenderRoute site => Yesod site where
- approot :: Approot site
- errorHandler :: ErrorResponse -> HandlerT site IO TypedContent
- defaultLayout :: WidgetT site IO () -> HandlerT site IO Html
- urlRenderOverride :: site -> Route site -> Maybe Builder
- isAuthorized :: Route site -> Bool -> HandlerT site IO AuthResult
- isWriteRequest :: Route site -> HandlerT site IO Bool
- authRoute :: site -> Maybe (Route site)
- cleanPath :: site -> [Text] -> Either [Text] [Text]
- joinPath :: site -> Text -> [Text] -> [(Text, Text)] -> Builder
- addStaticContent :: Text -> Text -> ByteString -> HandlerT site IO (Maybe (Either Text (Route site, [(Text, Text)])))
- maximumContentLength :: site -> Maybe (Route site) -> Maybe Word64
- makeLogger :: site -> IO Logger
- messageLoggerSource :: site -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- jsLoader :: site -> ScriptLoadPosition site
- makeSessionBackend :: site -> IO (Maybe SessionBackend)
- fileUpload :: site -> RequestBodyLength -> FileUpload
- shouldLog :: site -> LogSource -> LogLevel -> Bool
- shouldLogIO :: site -> LogSource -> LogLevel -> IO Bool
- yesodMiddleware :: ToTypedContent res => HandlerT site IO res -> HandlerT site IO res
- yesodWithInternalState :: site -> Maybe (Route site) -> (InternalState -> IO a) -> IO a
- class Yesod site => YesodDispatch site where
- yesodDispatch :: YesodRunnerEnv site -> Application
- class YesodSubDispatch sub m where
- yesodSubDispatch :: YesodSubRunnerEnv sub (HandlerSite m) m -> Application
- class Eq (Route a) => RenderRoute a where
- class RenderRoute a => ParseRoute a where
- class RenderRoute a => RouteAttrs a where
- routeAttrs :: Route a -> Set Text
- class YesodBreadcrumbs site where
- breadcrumbs :: YesodBreadcrumbs site => HandlerT site IO (Text, [(Route site, Text)])
- data Approot master
- = ApprootRelative
- | ApprootStatic !Text
- | ApprootMaster !(master -> Text)
- | ApprootRequest !(master -> Request -> Text)
- data FileUpload
- = FileUploadMemory !(BackEnd ByteString)
- | FileUploadDisk !(InternalState -> BackEnd FilePath)
- | FileUploadSource !(BackEnd (Source (ResourceT IO) ByteString))
- data ErrorResponse
- maybeAuthorized :: Yesod site => Route site -> Bool -> HandlerT site IO (Maybe (Route site))
- widgetToPageContent :: (Eq (Route site), Yesod site) => WidgetT site IO () -> HandlerT site IO (PageContent (Route site))
- defaultErrorHandler :: Yesod site => ErrorResponse -> HandlerT site IO TypedContent
- defaultYesodMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res
- authorizationCheck :: Yesod site => HandlerT site IO ()
- data AuthResult
- unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult
- defaultMakeLogger :: IO Logger
- defaultMessageLoggerSource :: (LogSource -> LogLevel -> IO Bool) -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- defaultShouldLog :: LogSource -> LogLevel -> Bool
- defaultShouldLogIO :: LogSource -> LogLevel -> IO Bool
- formatLogMessage :: IO ZonedDate -> Loc -> LogSource -> LogLevel -> LogStr -> IO LogStr
- data LogLevel :: *
- logDebug :: Q Exp
- logInfo :: Q Exp
- logWarn :: Q Exp
- logError :: Q Exp
- logOther :: Text -> Q Exp
- logDebugS :: Q Exp
- logInfoS :: Q Exp
- logWarnS :: Q Exp
- logErrorS :: Q Exp
- logOtherS :: Q Exp
- newtype SessionBackend = SessionBackend {
- sbLoadSession :: Request -> IO (SessionMap, SaveSession)
- customizeSessionCookies :: (SetCookie -> SetCookie) -> SessionBackend -> SessionBackend
- defaultClientSessionBackend :: Int -> FilePath -> IO SessionBackend
- envClientSessionBackend :: Int -> String -> IO SessionBackend
- clientSessionBackend :: Key -> IO ClientSessionDateCache -> SessionBackend
- sslOnlySessions :: IO (Maybe SessionBackend) -> IO (Maybe SessionBackend)
- sslOnlyMiddleware :: Yesod site => Int -> HandlerT site IO res -> HandlerT site IO res
- clientSessionDateCacher :: NominalDiffTime -> IO (IO ClientSessionDateCache, IO ())
- loadClientSession :: Key -> IO ClientSessionDateCache -> ByteString -> Request -> IO (SessionMap, SaveSession)
- data Header
- defaultCsrfMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res
- defaultCsrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res
- csrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> SetCookie -> HandlerT site IO res
- defaultCsrfCheckMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res
- csrfCheckMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO Bool -> CI ByteString -> Text -> HandlerT site IO res
- data ScriptLoadPosition master
- type BottomOfHeadAsync master = [Text] -> Maybe (HtmlUrl (Route master)) -> HtmlUrl (Route master)
- class MonadResource m => MonadHandler m where
- type HandlerSite m
- liftHandlerT :: HandlerT (HandlerSite m) IO a -> m a
- class MonadHandler m => MonadWidget m where
- liftWidgetT :: WidgetT (HandlerSite m) IO a -> m a
- getRouteToParent :: Monad m => HandlerT child (HandlerT parent m) (Route child -> Route parent)
- defaultLayoutSub :: Yesod parent => WidgetT child IO () -> HandlerT child (HandlerT parent IO) Html
- yesodVersion :: String
- yesodRender :: Yesod y => y -> ResolvedApproot -> Route y -> [(Text, Text)] -> Text
- runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> (site -> Logger) -> site -> HandlerT site IO a -> m (Either ErrorResponse a)
- newtype LiteApp = LiteApp {
- unLiteApp :: Method -> [Text] -> Maybe (LiteHandler TypedContent)
- type LiteHandler = HandlerT LiteApp IO
- type LiteWidget = WidgetT LiteApp IO
- 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 ()
- yesodRunner :: (ToTypedContent res, Yesod site) => HandlerT site IO res -> YesodRunnerEnv site -> Maybe (Route site) -> Application
- module Yesod.Core.Content
- module Yesod.Core.Dispatch
- module Yesod.Core.Handler
- module Yesod.Core.Widget
- module Yesod.Core.Json
- module Text.Shakespeare.I18N
- putTime :: UTCTime -> Put
- getTime :: Get UTCTime
- formatW3 :: UTCTime -> Text
- formatRFC1123 :: UTCTime -> Text
- formatRFC822 :: UTCTime -> Text
- module Text.Blaze.Html
- class MonadTrans t where
- class Monad m => MonadIO m where
- class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where
- liftBase :: b α -> m α
- class MonadBase b m => MonadBaseControl b m | m -> b
- class (MonadThrow m, MonadIO m, Applicative m, MonadBase IO m) => MonadResource m where
- liftResourceT :: ResourceT IO a -> m a
- class Monad m => MonadLogger m
- type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
- showIntegral :: Integral a => a -> String
- readIntegral :: Num a => String -> Maybe a
- hamlet :: QuasiQuoter
- shamlet :: QuasiQuoter
- xhamlet :: QuasiQuoter
- type HtmlUrl url = Render url -> Html
- julius :: QuasiQuoter
- type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript
- renderJavascriptUrl :: (url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text
- cassius :: QuasiQuoter
- lucius :: QuasiQuoter
- type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css
- renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text
Type classes
class RenderRoute site => Yesod site where Source
Define settings for a Yesod applications. All methods have intelligent defaults, and therefore no implementation is required.
Nothing
approot :: Approot site Source
An absolute URL to the root of the application. Do not include trailing slash.
Default value: ApprootRelative
. This is valid under the following
conditions:
- Your application is served from the root of the domain.
- You do not use any features that require absolute URLs, such as Atom feeds and XML sitemaps.
If this is not true, you should override with a different implementation.
errorHandler :: ErrorResponse -> HandlerT site IO TypedContent Source
Output error response pages.
Default value: defaultErrorHandler
.
defaultLayout :: WidgetT site IO () -> HandlerT site IO Html Source
Applies some form of layout to the contents of a page.
urlRenderOverride :: site -> Route site -> Maybe Builder Source
Override the rendering function for a particular URL. One use case for this is to offload static hosting to a different domain name to avoid sending cookies.
:: Route site | |
-> Bool | is this a write request? |
-> HandlerT site IO AuthResult |
Determine if a request is authorized or not.
Return Authorized
if the request is authorized,
Unauthorized
a message if unauthorized.
If authentication is required, return AuthenticationRequired
.
isWriteRequest :: Route site -> HandlerT site IO Bool Source
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
isAuthorized
.
authRoute :: site -> Maybe (Route site) Source
The default route for authentication.
Used in particular by isAuthorized
, but library users can do whatever
they want with it.
cleanPath :: site -> [Text] -> Either [Text] [Text] Source
A function used to clean up path segments. It returns Right
with a
clean path or Left
with a new set of pieces the user should be
redirected to. The default implementation enforces:
- No double slashes
- There is no trailing slash.
Note that versions of Yesod prior to 0.7 used a different set of rules involing trailing slashes.
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 cleanPath
.
:: Text | filename extension |
-> Text | mime-type |
-> ByteString | content |
-> HandlerT site IO (Maybe (Either Text (Route site, [(Text, Text)]))) |
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 Yesod.Widget module uses this feature.
The return value is Nothing
if no storing was performed; this is the
default implementation. A Just
Left
gives the absolute URL of the
file, whereas a Just
Right
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.
maximumContentLength :: site -> Maybe (Route site) -> Maybe Word64 Source
Maximum allowed length of the request body, in bytes.
If Nothing
, no maximum is applied.
Default: 2 megabytes.
makeLogger :: site -> IO Logger Source
Creates a Logger
to use for log messages.
Note that a common technique (endorsed by the scaffolding) is to create
a Logger
value and place it in your foundation datatype, and have this
method return that already created value. That way, you can use that
same Logger
for printing messages during app initialization.
Default: the defaultMakeLogger
function.
Send a message to the Logger
provided by getLogger
.
Default: the defaultMessageLoggerSource
function, using
shouldLogIO
to check whether we should log.
jsLoader :: site -> ScriptLoadPosition site Source
Where to Load sripts from. We recommend the default value,
BottomOfBody
. Alternatively use the built in async yepnope loader:
BottomOfHeadAsync $ loadJsYepnope $ Right $ StaticR js_modernizr_js
Or write your own async js loader.
makeSessionBackend :: site -> IO (Maybe SessionBackend) Source
Create a session backend. Returning Nothing
disables
sessions. If you'd like to change the way that the session
cookies are created, take a look at
customizeSessionCookies
.
Default: Uses clientsession with a 2 hour timeout.
fileUpload :: site -> RequestBodyLength -> FileUpload Source
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.
shouldLog :: site -> LogSource -> LogLevel -> Bool Source
Should we log the given log source/level combination.
Default: the defaultShouldLog
function.
shouldLogIO :: site -> LogSource -> LogLevel -> IO Bool Source
Should we log the given log source/level combination.
Note that this is almost identical to shouldLog
, except the result
lives in IO
. This allows you to dynamically alter the logging level of
your application by having this result depend on, e.g., an IORef
.
The default implementation simply uses shouldLog
. Future versions of
Yesod will remove shouldLog
and use this method exclusively.
Since 1.2.4
yesodMiddleware :: ToTypedContent res => HandlerT site IO res -> HandlerT site IO res Source
A Yesod middleware, which will wrap every handler function. This allows you to run code before and after a normal handler.
Default: the defaultYesodMiddleware
function.
Since: 1.1.6
yesodWithInternalState :: site -> Maybe (Route site) -> (InternalState -> IO a) -> IO a Source
How to allocate an InternalState
for each request.
The default implementation is almost always what you want. However, if
you know that you are never taking advantage of the MonadResource
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
class Yesod site => YesodDispatch site where Source
This class is automatically instantiated when you use the template haskell mkYesod function. You should never need to deal with it directly.
yesodDispatch :: YesodRunnerEnv site -> Application Source
class YesodSubDispatch sub m where Source
yesodSubDispatch :: YesodSubRunnerEnv sub (HandlerSite m) m -> Application Source
YesodSubDispatch WaiSubsite master |
class RenderRoute a => ParseRoute a where Source
class RenderRoute a => RouteAttrs a where Source
:: Route a | |
-> Set Text | A set of attributes associated with the route. |
Breadcrumbs
class YesodBreadcrumbs site where Source
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).
breadcrumbs :: YesodBreadcrumbs site => HandlerT site IO (Text, [(Route site, Text)]) Source
Gets the title of the current page and the hierarchy of parent pages, along with their respective titles.
Types
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 not pattern match on
Approot
values.
ApprootRelative | No application root. |
ApprootStatic !Text | |
ApprootMaster !(master -> Text) | |
ApprootRequest !(master -> Request -> Text) |
data FileUpload Source
data ErrorResponse Source
Responses to indicate some form of an error occurred.
Utitlities
Return the same URL if the user is authorized to see it.
Built on top of isAuthorized
. This is useful for building page that only
contain links to pages the user is allowed to see.
widgetToPageContent :: (Eq (Route site), Yesod site) => WidgetT site IO () -> HandlerT site IO (PageContent (Route site)) Source
Convert a widget to a PageContent
.
Defaults
defaultErrorHandler :: Yesod site => ErrorResponse -> HandlerT site IO TypedContent Source
The default error handler for errorHandler
.
defaultYesodMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res Source
Default implementation of yesodMiddleware
. Adds the response header
"Vary: Accept, Accept-Language" and performs authorization checks.
Since 1.2.0
authorizationCheck :: Yesod site => HandlerT site IO () Source
Check if a given request is authorized via isAuthorized
and
isWriteRequest
.
Since 1.2.0
Data types
data AuthResult Source
unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult Source
Return an Unauthorized
value, with the given i18n message.
Logging
defaultMakeLogger :: IO Logger Source
Default implementation of makeLogger
. Sends to stdout and
automatically flushes on each write.
Since 1.4.10
defaultMessageLoggerSource Source
:: (LogSource -> LogLevel -> IO Bool) | Check whether we should log this |
-> Logger | |
-> Loc | position in source code |
-> LogSource | |
-> LogLevel | |
-> LogStr | message |
-> IO () |
Default implementation of messageLoggerSource
. Checks if the
message should be logged using the provided function, and if so,
formats using formatLogMessage
. You can use defaultShouldLogIO
as the provided function.
Since 1.4.10
defaultShouldLog :: LogSource -> LogLevel -> Bool Source
defaultShouldLogIO :: LogSource -> LogLevel -> IO Bool Source
A default implementation of shouldLogIO
that can be used with
defaultMessageLoggerSource
. Just uses defaultShouldLog
.
Since 1.4.10
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 logDebugN
, this function does not include source
information. This currently works by checking to see if the
package name is the string "<unknown>". This is a hack,
but it removes some of the visual clutter from non-TH logs.
Since 1.4.10
data LogLevel :: *
Generates a function that takes a Text
and logs a LevelDebug
message. Usage:
$(logDebug) "This is a debug log message"
Generates a function that takes a Text
and logs a LevelOther
message. Usage:
$(logOther "My new level") "This is a log message"
Generates a function that takes a LogSource
and Text
and logs a LevelDebug
message. Usage:
$logDebugS "SomeSource" "This is a debug log message"
Generates a function that takes a LogSource
, a level name and a Text
and logs a LevelOther
message. Usage:
$logOtherS "SomeSource" "My new level" "This is a log message"
Sessions
newtype SessionBackend Source
SessionBackend | |
|
customizeSessionCookies :: (SetCookie -> SetCookie) -> SessionBackend -> SessionBackend Source
Customize the cookies used by the session backend. You may
use this function on your definition of makeSessionBackend
.
For example, you could set the cookie domain so that it would work across many subdomains:
makeSessionBackend site =
(fmap . fmap) (customizeSessionCookies addDomain) ...
where
addDomain cookie = cookie { setCookieDomain
= Just ".example.com" }
Default: Do not customize anything (id
).
defaultClientSessionBackend Source
:: Int | minutes |
-> FilePath | key file |
-> IO SessionBackend |
envClientSessionBackend Source
:: Int | minutes |
-> String | environment variable name |
-> IO SessionBackend |
Create a SessionBackend
which reads the session key from the named
environment variable.
This can be useful if:
- You can't rely on a persistent file system (e.g. Heroku)
- Your application is open source (e.g. you can't commit the key)
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:
- Run this code without the variable set, a value will be generated and
printed on
devstdout/
- Use
clientsession-generate
Since 1.4.5
:: Key | The encryption key |
-> IO ClientSessionDateCache | |
-> SessionBackend |
sslOnlySessions :: IO (Maybe SessionBackend) -> IO (Maybe SessionBackend) Source
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 sslOnlyMiddleware
with the site's
yesodMiddleware
.
Since 1.4.7
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 hijacking attacks on the sessions of users who attempt to access the site using an http url. This middleware makes a site functionally inaccessible over vanilla http in all standard browsers.
Since 1.4.7
clientSessionDateCacher Source
:: NominalDiffTime | Inactive session valitity. |
-> IO (IO ClientSessionDateCache, IO ()) |
:: Key | |
-> IO ClientSessionDateCache | |
-> ByteString | session name |
-> Request | |
-> IO (SessionMap, SaveSession) |
Headers to be added to a Result
.
CSRF protection
defaultCsrfMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res Source
Calls defaultCsrfSetCookieMiddleware
and defaultCsrfCheckMiddleware
. Use this midle
For details, see the "AJAX CSRF protection" section of Handler
.
Since 1.4.14
defaultCsrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res Source
Calls csrfSetCookieMiddleware
with the defaultCsrfCookieName
.
Since 1.4.14
csrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> SetCookie -> HandlerT site IO res Source
Takes a SetCookie
and overrides its value with a CSRF token, then sets the cookie. See setCsrfCookieWithCookie
.
For details, see the "AJAX CSRF protection" section of Handler
.
Since 1.4.14
defaultCsrfCheckMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res Source
Calls csrfCheckMiddleware
with isWriteRequest
, defaultCsrfHeaderName
, and defaultCsrfParamName
as parameters.
Since 1.4.14
:: Yesod site | |
=> HandlerT site IO res | |
-> HandlerT site IO Bool | Whether or not to perform the CSRF check. |
-> CI ByteString | The header name to lookup the CSRF token from. |
-> Text | The POST parameter name to lookup the CSRF token from. |
-> HandlerT site IO 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 PermissionDenied
error.
For details, see the "AJAX CSRF protection" section of Handler
.
Since 1.4.14
JS loaders
data ScriptLoadPosition master Source
type BottomOfHeadAsync master Source
Subsites
class MonadResource m => MonadHandler m where Source
type HandlerSite m Source
liftHandlerT :: HandlerT (HandlerSite m) IO a -> m a Source
MonadHandler m => MonadHandler (MaybeT m) | |
MonadHandler m => MonadHandler (ListT m) | |
MonadHandler m => MonadHandler (IdentityT m) | |
(Monoid w, MonadHandler m) => MonadHandler (WriterT w m) | |
(Monoid w, MonadHandler m) => MonadHandler (WriterT w m) | |
MonadHandler m => MonadHandler (StateT s m) | |
MonadHandler m => MonadHandler (StateT s m) | |
MonadHandler m => MonadHandler (ReaderT r m) | |
(Error e, MonadHandler m) => MonadHandler (ErrorT e m) | |
MonadResourceBase m => MonadHandler (WidgetT site m) | |
MonadResourceBase m => MonadHandler (HandlerT site m) | |
MonadHandler m => MonadHandler (ConduitM i o m) | |
(Monoid w, MonadHandler m) => MonadHandler (RWST r w s m) | |
(Monoid w, MonadHandler m) => MonadHandler (RWST r w s m) | |
MonadHandler m => MonadHandler (Pipe l i o u m) |
class MonadHandler m => MonadWidget m where Source
liftWidgetT :: WidgetT (HandlerSite m) IO a -> m a Source
MonadWidget m => MonadWidget (MaybeT m) | |
MonadWidget m => MonadWidget (ListT m) | |
MonadWidget m => MonadWidget (IdentityT m) | |
(Monoid w, MonadWidget m) => MonadWidget (WriterT w m) | |
(Monoid w, MonadWidget m) => MonadWidget (WriterT w m) | |
MonadWidget m => MonadWidget (StateT s m) | |
MonadWidget m => MonadWidget (StateT s m) | |
MonadWidget m => MonadWidget (ReaderT r m) | |
(Error e, MonadWidget m) => MonadWidget (ErrorT e m) | |
MonadResourceBase m => MonadWidget (WidgetT site m) | |
MonadWidget m => MonadWidget (ConduitM i o m) | |
(Monoid w, MonadWidget m) => MonadWidget (RWST r w s m) | |
(Monoid w, MonadWidget m) => MonadWidget (RWST r w s m) | |
MonadWidget m => MonadWidget (Pipe l i o u m) |
getRouteToParent :: Monad m => HandlerT child (HandlerT parent m) (Route child -> Route parent) Source
defaultLayoutSub :: Yesod parent => WidgetT child IO () -> HandlerT child (HandlerT parent IO) Html Source
Misc
runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> (site -> Logger) -> site -> HandlerT site IO a -> m (Either ErrorResponse a) Source
Deprecated: import runFakeHandler from Yesod.Core.Unsafe
LiteApp
LiteApp | |
|
type LiteHandler = HandlerT LiteApp IO Source
type LiteWidget = WidgetT LiteApp IO Source
dispatchTo :: ToTypedContent a => LiteHandler a -> Writer LiteApp () Source
withDynamicMulti :: PathMultiPiece ps => (ps -> Writer LiteApp ()) -> Writer LiteApp () Source
Low-level
yesodRunner :: (ToTypedContent res, Yesod site) => HandlerT site IO res -> YesodRunnerEnv site -> Maybe (Route site) -> Application Source
Re-exports
module Yesod.Core.Content
module Yesod.Core.Dispatch
module Yesod.Core.Handler
module Yesod.Core.Widget
module Yesod.Core.Json
module Text.Shakespeare.I18N
formatRFC1123 :: UTCTime -> Text Source
Format as per RFC 1123.
formatRFC822 :: UTCTime -> Text Source
Format as per RFC 822.
module Text.Blaze.Html
class MonadTrans t where
The class of monad transformers. Instances should satisfy the
following laws, which state that lift
is a monad transformation:
MonadTrans MaybeT | |
MonadTrans CatchT | |
MonadTrans NoLoggingT | |
MonadTrans LoggingT | |
MonadTrans ListT | |
MonadTrans ResourceT | |
MonadTrans IdentityT | |
Monoid w => MonadTrans (WriterT w) | |
Monoid w => MonadTrans (WriterT w) | |
MonadTrans (StateT s) | |
MonadTrans (StateT s) | |
MonadTrans (ReaderT r) | |
MonadTrans (ErrorT e) | |
MonadTrans (ContT r) | |
MonadTrans (ExceptT e) | |
MonadTrans (WidgetT site) | |
MonadTrans (HandlerT site) | |
MonadTrans (ConduitM i o) | |
Monoid w => MonadTrans (RWST r w s) | |
Monoid w => MonadTrans (RWST r w s) | |
MonadTrans (Pipe l i o u) |
class Monad m => MonadIO m where
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
MonadIO IO | |
MonadIO m => MonadIO (MaybeT m) | |
MonadIO m => MonadIO (CatchT m) | |
MonadIO m => MonadIO (NoLoggingT m) | |
MonadIO m => MonadIO (LoggingT m) | |
MonadIO m => MonadIO (ListT m) | |
MonadIO m => MonadIO (ResourceT m) | |
MonadIO m => MonadIO (IdentityT m) | |
(Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
(Monoid w, MonadIO m) => MonadIO (WriterT w m) | |
MonadIO m => MonadIO (StateT s m) | |
MonadIO m => MonadIO (StateT s m) | |
MonadIO m => MonadIO (ReaderT r m) | |
(Error e, MonadIO m) => MonadIO (ErrorT e m) | |
MonadIO m => MonadIO (ContT r m) | |
MonadIO m => MonadIO (ExceptT e m) | |
MonadIO m => MonadIO (WidgetT site m) | |
MonadIO m => MonadIO (HandlerT site m) | |
MonadIO m => MonadIO (ConduitM i o m) | |
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) | |
MonadIO m => MonadIO (Pipe l i o u m) |
class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where
liftBase :: b α -> m α
Lift a computation from the base monad
class MonadBase b m => MonadBaseControl b m | m -> b
class (MonadThrow m, MonadIO m, Applicative m, MonadBase IO m) => MonadResource m where
A Monad
which allows for safe resource allocation. In theory, any monad
transformer stack included a ResourceT
can be an instance of
MonadResource
.
Note: runResourceT
has a requirement for a MonadBaseControl IO m
monad,
which allows control operations to be lifted. A MonadResource
does not
have this requirement. This means that transformers such as ContT
can be
an instance of MonadResource
. However, the ContT
wrapper will need to be
unwrapped before calling runResourceT
.
Since 0.3.0
liftResourceT :: ResourceT IO a -> m a
Lift a ResourceT IO
action into the current Monad
.
Since 0.4.0
class Monad m => MonadLogger m
A Monad
which has the ability to log messages in some manner.
MonadLogger m => MonadLogger (MaybeT m) | |
Monad m => MonadLogger (NoLoggingT m) | |
MonadIO m => MonadLogger (LoggingT m) | |
MonadLogger m => MonadLogger (ListT m) | |
MonadLogger m => MonadLogger (ResourceT m) | |
MonadLogger m => MonadLogger (IdentityT m) | |
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) | |
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) | |
MonadLogger m => MonadLogger (StateT s m) | |
MonadLogger m => MonadLogger (StateT s m) | |
MonadLogger m => MonadLogger (ReaderT r m) | |
(MonadLogger m, Error e) => MonadLogger (ErrorT e m) | |
MonadLogger m => MonadLogger (ContT r m) | |
MonadLogger m => MonadLogger (ExceptT e m) | |
MonadIO m => MonadLogger (WidgetT site m) | |
MonadIO m => MonadLogger (HandlerT site m) | |
MonadLogger m => MonadLogger (ConduitM i o m) | |
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) | |
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) | |
MonadLogger m => MonadLogger (Pipe l i o u m) |
Commonly referenced functions/datatypes
type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
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., ResourceT
). As a demonstration:
app :: Application app req respond = bracket_ (putStrLn "Allocating scarce resource") (putStrLn "Cleaning up") (respond $ responseLBS status200 [] "Hello World")
Utilities
showIntegral :: Integral a => a -> String Source
readIntegral :: Num a => String -> Maybe a Source
Shakespeare
Hamlet
Julius
type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript
Return type of template-reading functions.
renderJavascriptUrl :: (url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text
render with route interpolation. If using this module standalone, apart from type-safe routes, a dummy renderer can be used:
renderJavascriptUrl (\_ _ -> undefined) javascriptUrl
When using Yesod, a renderer is generated for you, which can be accessed
within the GHandler monad: getUrlRenderParams
.
Cassius/Lucius
>>>
renderCss ([lucius|foo{bar:baz}|] undefined)
"foo{bar:baz}"