yesod-core-1.4.31: Creation of type-safe, RESTful web applications.

Safe Haskell | None
Language | Haskell98

Yesod.Core

Contents

- Type classes
  - Breadcrumbs
- Types
- Utilities
- Defaults
- Data types
- Logging
- Sessions
- CSRF protection
- JS loaders
- Subsites
- Approot
- Misc
- LiteApp
- Low-level
- Re-exports
- Commonly referenced functions/datatypes
- Utilities
- Shakespeare
  - Hamlet
  - Julius
  - Cassius/Lucius

Synopsis

- class RenderRoute site => Yesod site where
- class Yesod site => YesodDispatch site where
- class YesodSubDispatch sub m where
- class Eq (Route a) => RenderRoute a where
  - data Route a
- class RenderRoute a => ParseRoute a where
- class RenderRoute a => RouteAttrs a where
- 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
  - = NotFound
  - | InternalError Text
  - | InvalidArgs [Text]
  - | NotAuthenticated
  - | PermissionDenied Text
  - | BadMethod Method
- 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
  - = Authorized
  - | AuthenticationRequired
  - | Unauthorized Text
- 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 :: *
  - = LevelDebug
  - | LevelInfo
  - | LevelWarn
  - | LevelError
  - | LevelOther Text
- 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)
- laxSameSiteSessions :: IO (Maybe SessionBackend) -> IO (Maybe SessionBackend)
- strictSameSiteSessions :: 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
  - = AddCookie SetCookie
  - | DeleteCookie ByteString ByteString
  - | Header ByteString ByteString
- 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
  - = BottomOfBody
  - | BottomOfHeadBlocking
  - | BottomOfHeadAsync (BottomOfHeadAsync master)
- type BottomOfHeadAsync master = [Text] -> Maybe (HtmlUrl (Route master)) -> HtmlUrl (Route master)
- class MonadResource m => MonadHandler m where
  - type HandlerSite m
- class MonadHandler m => MonadWidget m where
- getRouteToParent :: Monad m => HandlerT child (HandlerT parent m) (Route child -> Route parent)
- defaultLayoutSub :: Yesod parent => WidgetT child IO () -> HandlerT child (HandlerT parent IO) Html
- guessApproot :: Approot site
- guessApprootOr :: Approot site -> Approot site
- getApprootText :: Approot site -> site -> Request -> Text
- 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
- getCurrentMaxExpiresRFC1123 :: IO Text
- module Text.Blaze.Html
- class MonadTrans t where
  - lift :: Monad m => m a -> t m a
- class Monad m => MonadIO m where
  - liftIO :: IO a -> m a
- 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 #

Define settings for a Yesod applications. All methods have intelligent defaults, and therefore no implementation is required.

Methods

approot :: Approot site #

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 #

Output error response pages.

Default value: `defaultErrorHandler`.

defaultLayout :: WidgetT site IO () -> HandlerT site IO Html #

Applies some form of layout to the contents of a page.

urlRenderOverride :: site -> Route site -> Maybe Builder #

Deprecated: Use urlParamRenderOverride instead

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.

urlParamRenderOverride :: site -> Route site -> [(Text, Text)] -> Maybe Builder #

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 `urlRenderOverride`, probably ineffective

Since 1.4.23

isAuthorized :: Route site -> Bool -> 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 #

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

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

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.

joinPath :: site -> Text -> [Text] -> [(Text, Text)] -> Builder #

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

addStaticContent :: Text -> Text -> ByteString -> 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 #

Maximum allowed length of the request body, in bytes.

If `Nothing`, no maximum is applied.

Default: 2 megabytes.

makeLogger :: site -> IO Logger #

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.

messageLoggerSource :: site -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO () #

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 #

Where to Load sripts from. We recommend the default value, `BottomOfBody`.

jsAttributes :: site -> [(Text, Text)] #

Default attributes to put on the JavaScript script tag generated for julius files

makeSessionBackend :: site -> IO (Maybe SessionBackend) #

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 #

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 #

Should we log the given log source/level combination.

Default: the `defaultShouldLog` function.

shouldLogIO :: site -> LogSource -> LogLevel -> IO Bool #

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 #

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 #

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

defaultMessageWidget :: Html -> HtmlUrl (Route site) -> WidgetT site IO () #

Convert a title and HTML snippet into a `Widget`. Used primarily for wrapping up error messages for better display.

Since: 1.4.30

Instances

Yesod LiteApp # |
Methods approot :: Approot LiteApp # errorHandler :: ErrorResponse -> HandlerT LiteApp IO TypedContent # defaultLayout :: WidgetT LiteApp IO () -> HandlerT LiteApp IO Html # urlRenderOverride :: LiteApp -> Route LiteApp -> Maybe Builder # urlParamRenderOverride :: LiteApp -> Route LiteApp -> [(Text, Text)] -> Maybe Builder # isAuthorized :: Route LiteApp -> Bool -> HandlerT LiteApp IO AuthResult # isWriteRequest :: Route LiteApp -> HandlerT LiteApp IO Bool # authRoute :: LiteApp -> Maybe (Route LiteApp) # cleanPath :: LiteApp -> [Text] -> Either [Text] [Text] # joinPath :: LiteApp -> Text -> [Text] -> [(Text, Text)] -> Builder # addStaticContent :: Text -> Text -> ByteString -> HandlerT LiteApp IO (Maybe (Either Text (Route LiteApp, [(Text, Text)]))) # maximumContentLength :: LiteApp -> Maybe (Route LiteApp) -> Maybe Word64 # makeLogger :: LiteApp -> IO Logger # messageLoggerSource :: LiteApp -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO () # jsLoader :: LiteApp -> ScriptLoadPosition LiteApp # jsAttributes :: LiteApp -> [(Text, Text)] # makeSessionBackend :: LiteApp -> IO (Maybe SessionBackend) # fileUpload :: LiteApp -> RequestBodyLength -> FileUpload # shouldLog :: LiteApp -> LogSource -> LogLevel -> Bool # shouldLogIO :: LiteApp -> LogSource -> LogLevel -> IO Bool # yesodMiddleware :: ToTypedContent res => HandlerT LiteApp IO res -> HandlerT LiteApp IO res # yesodWithInternalState :: LiteApp -> Maybe (Route LiteApp) -> (InternalState -> IO a) -> IO a # defaultMessageWidget :: Html -> HtmlUrl (Route LiteApp) -> WidgetT LiteApp IO () #

class Yesod site => YesodDispatch site where #

This class is automatically instantiated when you use the template haskell mkYesod function. You should never need to deal with it directly.

Minimal complete definition

yesodDispatch

Methods

yesodDispatch :: YesodRunnerEnv site -> Application #

Instances

YesodDispatch LiteApp # |
Methods yesodDispatch :: YesodRunnerEnv LiteApp -> Application #

class YesodSubDispatch sub m where #

Minimal complete definition

yesodSubDispatch

Methods

yesodSubDispatch :: YesodSubRunnerEnv sub (HandlerSite m) m -> Application #

Instances

YesodSubDispatch WaiSubsite master # |
Methods yesodSubDispatch :: YesodSubRunnerEnv WaiSubsite (HandlerSite master) master -> Application #

class Eq (Route a) => RenderRoute a where #

Minimal complete definition

renderRoute

Associated Types

data Route a #

The type-safe URLs associated with a site argument.

Methods

renderRoute :: Route a -> ([Text], [(Text, Text)]) #

Instances

RenderRoute WaiSubsite # |
Associated Types data Route WaiSubsite :: * # Methods renderRoute :: Route WaiSubsite -> ([Text], [(Text, Text)]) #
RenderRoute LiteApp # |
Associated Types data Route LiteApp :: * # Methods renderRoute :: Route LiteApp -> ([Text], [(Text, Text)]) #

class RenderRoute a => ParseRoute a where #

Minimal complete definition

parseRoute

Methods

parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route a) #

Instances

ParseRoute WaiSubsite # |
Methods parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route WaiSubsite) #
ParseRoute LiteApp # |
Methods parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route LiteApp) #

class RenderRoute a => RouteAttrs a where #

Minimal complete definition

routeAttrs

Methods

routeAttrs :: Route a -> Set Text #

## Breadcrumbs

class YesodBreadcrumbs site where #

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

Minimal complete definition

breadcrumb

Methods

breadcrumb :: Route site -> HandlerT site IO (Text, Maybe (Route site)) #

Returns the title and the parent resource, if available. If you return a `Nothing`, then this is considered a top-level page.

breadcrumbs :: YesodBreadcrumbs site => HandlerT site IO (Text, [(Route site, Text)]) #

Gets the title of the current page and the hierarchy of parent pages, along with their respective titles.

# Types

data Approot master #

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.

Constructors

ApprootRelative | No application root.
ApprootStatic !Text |
ApprootMaster !(master -> Text) |
ApprootRequest !(master -> Request -> Text) |

data FileUpload #

Constructors

FileUploadMemory !(BackEnd ByteString) |
FileUploadDisk !(InternalState -> BackEnd FilePath) |
FileUploadSource !(BackEnd (Source (ResourceT IO) ByteString)) |

data ErrorResponse #

Responses to indicate some form of an error occurred.

Constructors

NotFound |
InternalError Text |
InvalidArgs [Text] |
NotAuthenticated |
PermissionDenied Text |
BadMethod Method |

Instances

Eq ErrorResponse # |
Methods (==) :: ErrorResponse -> ErrorResponse -> Bool # (/=) :: ErrorResponse -> ErrorResponse -> Bool #
Show ErrorResponse # |
Methods showsPrec :: Int -> ErrorResponse -> ShowS # show :: ErrorResponse -> String # showList :: [ErrorResponse] -> ShowS #
Generic ErrorResponse # |
Associated Types type Rep ErrorResponse :: * -> * # Methods from :: ErrorResponse -> Rep ErrorResponse x # to :: Rep ErrorResponse x -> ErrorResponse #
NFData ErrorResponse # |
Methods rnf :: ErrorResponse -> () #
type Rep ErrorResponse # |
type Rep ErrorResponse = D1 (MetaData "ErrorResponse" "Yesod.Core.Types" "yesod-core-1.4.31-In0kfFmAB0pFD51cgqrjPT" False) ((:+:) ((:+:) (C1 (MetaCons "NotFound" PrefixI False) U1) ((:+:) (C1 (MetaCons "InternalError" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))) (C1 (MetaCons "InvalidArgs" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Text]))))) ((:+:) (C1 (MetaCons "NotAuthenticated" PrefixI False) U1) ((:+:) (C1 (MetaCons "PermissionDenied" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))) (C1 (MetaCons "BadMethod" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Method))))))

# Utilities

maybeAuthorized #

Arguments

:: Yesod site |
=> Route site |
-> Bool | is this a write request?
-> HandlerT site IO (Maybe (Route site)) |

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

Convert a widget to a `PageContent`.

# Defaults

defaultErrorHandler :: Yesod site => ErrorResponse -> HandlerT site IO TypedContent #

The default error handler for `errorHandler`.

defaultYesodMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res #

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 () #

Check if a given request is authorized via `isAuthorized` and `isWriteRequest`.

Since 1.2.0

# Data types

data AuthResult #

Constructors

Authorized |
AuthenticationRequired |
Unauthorized Text |

Instances

Eq AuthResult # |
Methods (==) :: AuthResult -> AuthResult -> Bool # (/=) :: AuthResult -> AuthResult -> Bool #
Read AuthResult # |
Methods readsPrec :: Int -> ReadS AuthResult # readList :: ReadS [AuthResult] # readPrec :: ReadPrec AuthResult # readListPrec :: ReadPrec [AuthResult] #
Show AuthResult # |
Methods showsPrec :: Int -> AuthResult -> ShowS # show :: AuthResult -> String # showList :: [AuthResult] -> ShowS #

unauthorizedI :: (MonadHandler m, RenderMessage (HandlerSite m) msg) => msg -> m AuthResult #

Return an `Unauthorized` value, with the given i18n message.

# Logging

defaultMakeLogger :: IO Logger #

Default implementation of `makeLogger`. Sends to stdout and automatically flushes on each write.

Since 1.4.10

defaultMessageLoggerSource #

Arguments

:: (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 #

Default implementation of `shouldLog`. Logs everything at or above `LevelInfo`.

Since 1.4.10

defaultShouldLogIO :: LogSource -> LogLevel -> IO Bool #

A default implementation of `shouldLogIO` that can be used with `defaultMessageLoggerSource`. Just uses `defaultShouldLog`.

Since 1.4.10

formatLogMessage #

Arguments

:: IO ZonedDate |
-> Loc |
-> LogSource |
-> LogLevel |
-> LogStr | message
-> IO LogStr |

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 :: * #

Constructors

LevelDebug |
LevelInfo |
LevelWarn |
LevelError |
LevelOther Text |

Instances

Eq LogLevel |
Methods (==) :: LogLevel -> LogLevel -> Bool # (/=) :: LogLevel -> LogLevel -> Bool #
Ord LogLevel |
Methods compare :: LogLevel -> LogLevel -> Ordering # (<) :: LogLevel -> LogLevel -> Bool # (<=) :: LogLevel -> LogLevel -> Bool # (>) :: LogLevel -> LogLevel -> Bool # (>=) :: LogLevel -> LogLevel -> Bool # max :: LogLevel -> LogLevel -> LogLevel # min :: LogLevel -> LogLevel -> LogLevel #
Read LogLevel |
Methods readsPrec :: Int -> ReadS LogLevel # readList :: ReadS [LogLevel] # readPrec :: ReadPrec LogLevel # readListPrec :: ReadPrec [LogLevel] #
Show LogLevel |
Methods showsPrec :: Int -> LogLevel -> ShowS # show :: LogLevel -> String # showList :: [LogLevel] -> ShowS #
Lift LogLevel |
Methods lift :: LogLevel -> Q Exp #

logDebug :: Q Exp #

Generates a function that takes a `Text` and logs a `LevelDebug` message. Usage:

    $(logDebug) "This is a debug log message"

logInfo :: Q Exp #

See `logDebug`

logWarn :: Q Exp #

See `logDebug`

logError :: Q Exp #

See `logDebug`

logOther :: Text -> Q Exp #

Generates a function that takes a `Text` and logs a `LevelOther` message. Usage:

    $(logOther "My new level") "This is a log message"

logDebugS :: Q Exp #

Generates a function that takes a `LogSource` and `Text` and logs a `LevelDebug` message. Usage:

    $logDebugS "SomeSource" "This is a debug log message"

logInfoS :: Q Exp #

See `logDebugS`

logWarnS :: Q Exp #

See `logDebugS`

logErrorS :: Q Exp #

See `logDebugS`

logOtherS :: Q Exp #

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 #

Constructors

SessionBackend |
Fields sbLoadSession :: Request -> IO (SessionMap, SaveSession) Return the session data and a function to save the session

customizeSessionCookies :: (SetCookie -> SetCookie) -> SessionBackend -> SessionBackend #

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 #

Arguments

:: Int | minutes
-> FilePath | key file
-> IO SessionBackend |

envClientSessionBackend #

Arguments

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

1. You can't rely on a persistent file system (e.g. Heroku)
2. 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:

1. Run this code without the variable set, a value will be generated and printed on `devstdout/`
2. Use `clientsession-generate`

Since 1.4.5

clientSessionBackend #

Arguments

:: Key | The encryption key
-> IO ClientSessionDateCache | See `clientSessionDateCacher`
-> SessionBackend |

sslOnlySessions :: IO (Maybe SessionBackend) -> IO (Maybe SessionBackend) #

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

laxSameSiteSessions :: 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 here.

Since: 1.4.23

strictSameSiteSessions :: 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 here.

Since: 1.4.23

sslOnlyMiddleware #

Arguments

:: Yesod site |
=> Int | minutes
-> HandlerT site IO res |
-> HandlerT site IO res |

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

clientSessionDateCacher #

Arguments

:: NominalDiffTime | Inactive session validity.
-> IO (IO ClientSessionDateCache, IO ()) |

loadClientSession #

Arguments

:: Key |
-> IO ClientSessionDateCache | See `clientSessionDateCacher`
-> ByteString | session name
-> Request |
-> IO (SessionMap, SaveSession) |

data Header #

Headers to be added to a `Result`.

Constructors

AddCookie SetCookie |
DeleteCookie ByteString ByteString |
Header ByteString ByteString |

Instances

Eq Header # |
Methods (==) :: Header -> Header -> Bool # (/=) :: Header -> Header -> Bool #
Show Header # |
Methods showsPrec :: Int -> Header -> ShowS # show :: Header -> String # showList :: [Header] -> ShowS #
NFData Header # |
Methods rnf :: Header -> () #

# CSRF protection

defaultCsrfMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res #

Calls `defaultCsrfSetCookieMiddleware` and `defaultCsrfCheckMiddleware`.

For details, see the "AJAX CSRF protection" section of Yesod.Core.Handler.

You can add this chain this middleware together with other middleware like so:

    yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware

or:

    yesodMiddleware app = defaultYesodMiddleware $ defaultCsrfMiddleware $ app

Since 1.4.14

defaultCsrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res #

Calls `csrfSetCookieMiddleware` with the `defaultCsrfCookieName`.

The cookie's path is set to `/`, making it valid for your whole website.

Since 1.4.14

csrfSetCookieMiddleware :: Yesod site => HandlerT site IO res -> SetCookie -> HandlerT site IO res #

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 Yesod.Core.Handler.

Make sure to set the `setCookiePath` 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 `app1`. The vast majority of sites will just use `/`.

Since 1.4.14

defaultCsrfCheckMiddleware :: Yesod site => HandlerT site IO res -> HandlerT site IO res #

Calls `csrfCheckMiddleware` with `isWriteRequest`, `defaultCsrfHeaderName`, and `defaultCsrfParamName` as parameters.

Since 1.4.14

csrfCheckMiddleware #

Arguments

:: 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 Yesod.Core.Handler.

Since 1.4.14

# JS loaders

data ScriptLoadPosition master #

Constructors

BottomOfBody |
BottomOfHeadBlocking |
BottomOfHeadAsync (BottomOfHeadAsync master) |

type BottomOfHeadAsync master #

Arguments

= [Text] | urls to load asynchronously
-> Maybe (HtmlUrl (Route master)) | widget of js to run on async completion
-> HtmlUrl (Route master) | widget to insert at the bottom of head

# Subsites

class MonadResource m => MonadHandler m where #

Minimal complete definition

liftHandlerT

Associated Types

type HandlerSite m #

Methods

liftHandlerT :: HandlerT (HandlerSite m) IO a -> m a #

Instances

MonadHandler m => MonadHandler (MaybeT m) # |
Associated Types type HandlerSite (MaybeT m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (MaybeT m)) IO a -> MaybeT m a #
MonadHandler m => MonadHandler (ListT m) # |
Associated Types type HandlerSite (ListT m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (ListT m)) IO a -> ListT m a #
(Monoid w, MonadHandler m) => MonadHandler (WriterT w m) # |
Associated Types type HandlerSite (WriterT w m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (WriterT w m)) IO a -> WriterT w m a #
(Monoid w, MonadHandler m) => MonadHandler (WriterT w m) # |
Associated Types type HandlerSite (WriterT w m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (WriterT w m)) IO a -> WriterT w m a #
MonadHandler m => MonadHandler (StateT s m) # |
Associated Types type HandlerSite (StateT s m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (StateT s m)) IO a -> StateT s m a #
MonadHandler m => MonadHandler (StateT s m) # |
Associated Types type HandlerSite (StateT s m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (StateT s m)) IO a -> StateT s m a #
(Error e, MonadHandler m) => MonadHandler (ErrorT e m) # |
Associated Types type HandlerSite (ErrorT e m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (ErrorT e m)) IO a -> ErrorT e m a #
MonadHandler m => MonadHandler (ExceptT e m) # |
Associated Types type HandlerSite (ExceptT e m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (ExceptT e m)) IO a -> ExceptT e m a #
MonadHandler m => MonadHandler (IdentityT * m) # |
Associated Types type HandlerSite (IdentityT * m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (IdentityT * m)) IO a -> IdentityT * m a #
MonadResourceBase m => MonadHandler (WidgetT site m) # |
Associated Types type HandlerSite (WidgetT site m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (WidgetT site m)) IO a -> WidgetT site m a #
MonadResourceBase m => MonadHandler (HandlerT site m) # |
Associated Types type HandlerSite (HandlerT site m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (HandlerT site m)) IO a -> HandlerT site m a #
MonadHandler m => MonadHandler (ReaderT * r m) # |
Associated Types type HandlerSite (ReaderT * r m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (ReaderT * r m)) IO a -> ReaderT * r m a #
MonadHandler m => MonadHandler (ConduitM i o m) # |
Associated Types type HandlerSite (ConduitM i o m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (ConduitM i o m)) IO a -> ConduitM i o m a #
(Monoid w, MonadHandler m) => MonadHandler (RWST r w s m) # |
Associated Types type HandlerSite (RWST r w s m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (RWST r w s m)) IO a -> RWST r w s m a #
(Monoid w, MonadHandler m) => MonadHandler (RWST r w s m) # |
Associated Types type HandlerSite (RWST r w s m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (RWST r w s m)) IO a -> RWST r w s m a #
MonadHandler m => MonadHandler (Pipe l i o u m) # |
Associated Types type HandlerSite (Pipe l i o u m :: * -> *) :: * # Methods liftHandlerT :: HandlerT (HandlerSite (Pipe l i o u m)) IO a -> Pipe l i o u m a #

class MonadHandler m => MonadWidget m where #

Minimal complete definition

liftWidgetT

Methods

liftWidgetT :: WidgetT (HandlerSite m) IO a -> m a #

Instances

MonadWidget m => MonadWidget (MaybeT m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (MaybeT m)) IO a -> MaybeT m a #
MonadWidget m => MonadWidget (ListT m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (ListT m)) IO a -> ListT m a #
(Monoid w, MonadWidget m) => MonadWidget (WriterT w m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (WriterT w m)) IO a -> WriterT w m a #
(Monoid w, MonadWidget m) => MonadWidget (WriterT w m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (WriterT w m)) IO a -> WriterT w m a #
MonadWidget m => MonadWidget (StateT s m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (StateT s m)) IO a -> StateT s m a #
MonadWidget m => MonadWidget (StateT s m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (StateT s m)) IO a -> StateT s m a #
(Error e, MonadWidget m) => MonadWidget (ErrorT e m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (ErrorT e m)) IO a -> ErrorT e m a #
MonadWidget m => MonadWidget (ExceptT e m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (ExceptT e m)) IO a -> ExceptT e m a #
MonadWidget m => MonadWidget (IdentityT * m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (IdentityT * m)) IO a -> IdentityT * m a #
MonadResourceBase m => MonadWidget (WidgetT site m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (WidgetT site m)) IO a -> WidgetT site m a #
MonadWidget m => MonadWidget (ReaderT * r m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (ReaderT * r m)) IO a -> ReaderT * r m a #
MonadWidget m => MonadWidget (ConduitM i o m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (ConduitM i o m)) IO a -> ConduitM i o m a #
(Monoid w, MonadWidget m) => MonadWidget (RWST r w s m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (RWST r w s m)) IO a -> RWST r w s m a #
(Monoid w, MonadWidget m) => MonadWidget (RWST r w s m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (RWST r w s m)) IO a -> RWST r w s m a #
MonadWidget m => MonadWidget (Pipe l i o u m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (Pipe l i o u m)) IO a -> Pipe l i o u 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 #

# Approot

guessApproot :: Approot site #

Guess the approot based on request headers. For more information, see Network.Wai.Middleware.Approot

In the case of headers being unavailable, it falls back to `ApprootRelative`

Since 1.4.16

guessApprootOr :: Approot site -> Approot site #

Guess the approot based on request headers, with fall back to the specified `AppRoot`.

Since 1.4.16

getApprootText :: Approot site -> site -> Request -> Text #

Get the textual application root from an `Approot` value.

Since 1.4.17

# Misc

yesodVersion :: String #

yesodRender #

Arguments

:: Yesod y |
=> y |
-> ResolvedApproot |
-> Route y |
-> [(Text, Text)] | url query string
-> Text |

runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> (site -> Logger) -> site -> HandlerT site IO a -> m (Either ErrorResponse a) #

Deprecated: import runFakeHandler from Yesod.Core.Unsafe

# LiteApp

newtype LiteApp #

Constructors

LiteApp |
Fields unLiteApp :: Method -> [Text] -> Maybe (LiteHandler TypedContent)

Instances

Monoid LiteApp # |
Methods mempty :: LiteApp # mappend :: LiteApp -> LiteApp -> LiteApp # mconcat :: [LiteApp] -> LiteApp #
ParseRoute LiteApp # |
Methods parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route LiteApp) #
RenderRoute LiteApp # |
Associated Types data Route LiteApp :: * # Methods renderRoute :: Route LiteApp -> ([Text], [(Text, Text)]) #
Yesod LiteApp # |
Methods approot :: Approot LiteApp # errorHandler :: ErrorResponse -> HandlerT LiteApp IO TypedContent # defaultLayout :: WidgetT LiteApp IO () -> HandlerT LiteApp IO Html # urlRenderOverride :: LiteApp -> Route LiteApp -> Maybe Builder # urlParamRenderOverride :: LiteApp -> Route LiteApp -> [(Text, Text)] -> Maybe Builder # isAuthorized :: Route LiteApp -> Bool -> HandlerT LiteApp IO AuthResult # isWriteRequest :: Route LiteApp -> HandlerT LiteApp IO Bool # authRoute :: LiteApp -> Maybe (Route LiteApp) # cleanPath :: LiteApp -> [Text] -> Either [Text] [Text] # joinPath :: LiteApp -> Text -> [Text] -> [(Text, Text)] -> Builder # addStaticContent :: Text -> Text -> ByteString -> HandlerT LiteApp IO (Maybe (Either Text (Route LiteApp, [(Text, Text)]))) # maximumContentLength :: LiteApp -> Maybe (Route LiteApp) -> Maybe Word64 # makeLogger :: LiteApp -> IO Logger # messageLoggerSource :: LiteApp -> Logger -> Loc -> LogSource -> LogLevel -> LogStr -> IO () # jsLoader :: LiteApp -> ScriptLoadPosition LiteApp # jsAttributes :: LiteApp -> [(Text, Text)] # makeSessionBackend :: LiteApp -> IO (Maybe SessionBackend) # fileUpload :: LiteApp -> RequestBodyLength -> FileUpload # shouldLog :: LiteApp -> LogSource -> LogLevel -> Bool # shouldLogIO :: LiteApp -> LogSource -> LogLevel -> IO Bool # yesodMiddleware :: ToTypedContent res => HandlerT LiteApp IO res -> HandlerT LiteApp IO res # yesodWithInternalState :: LiteApp -> Maybe (Route LiteApp) -> (InternalState -> IO a) -> IO a # defaultMessageWidget :: Html -> HtmlUrl (Route LiteApp) -> WidgetT LiteApp IO () #
YesodDispatch LiteApp # |
Methods yesodDispatch :: YesodRunnerEnv LiteApp -> Application #
Eq (Route LiteApp) # |
Methods (==) :: Route LiteApp -> Route LiteApp -> Bool # (/=) :: Route LiteApp -> Route LiteApp -> Bool #
Ord (Route LiteApp) # |
Methods compare :: Route LiteApp -> Route LiteApp -> Ordering # (<) :: Route LiteApp -> Route LiteApp -> Bool # (<=) :: Route LiteApp -> Route LiteApp -> Bool # (>) :: Route LiteApp -> Route LiteApp -> Bool # (>=) :: Route LiteApp -> Route LiteApp -> Bool # max :: Route LiteApp -> Route LiteApp -> Route LiteApp # min :: Route LiteApp -> Route LiteApp -> Route LiteApp #
Read (Route LiteApp) # |
Methods readsPrec :: Int -> ReadS (Route LiteApp) # readList :: ReadS [Route LiteApp] # readPrec :: ReadPrec (Route LiteApp) # readListPrec :: ReadPrec [Route LiteApp] #
Show (Route LiteApp) # |
Methods showsPrec :: Int -> Route LiteApp -> ShowS # show :: Route LiteApp -> String # showList :: [Route LiteApp] -> ShowS #
data Route LiteApp # |
data Route LiteApp = LiteAppRoute [Text]

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 () #

# Low-level

yesodRunner :: (ToTypedContent res, Yesod site) => HandlerT site IO res -> YesodRunnerEnv site -> Maybe (Route site) -> Application #

# 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

putTime :: UTCTime -> Put #

getTime :: Get UTCTime #

formatW3 :: UTCTime -> Text #

Format a `UTCTime` in W3 format.

formatRFC1123 :: UTCTime -> Text #

Format as per RFC 1123.

formatRFC822 :: UTCTime -> Text #

Format as per RFC 822.

getCurrentMaxExpiresRFC1123 :: IO Text #

Get the time 365 days from now in RFC 1123 format. For use as an expiry date on a resource that never expires. See RFC 2616 section 14.21 for details.

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:

-     lift . return = return

-     lift (m >>= f) = lift m >>= (lift . f)

Instances

MonadTrans MaybeT |
Methods lift :: Monad m => m a -> MaybeT m a #
MonadTrans CatchT |
Methods lift :: Monad m => m a -> CatchT m a #
MonadTrans NoLoggingT |
Methods lift :: Monad m => m a -> NoLoggingT m a #
MonadTrans LoggingT |
Methods lift :: Monad m => m a -> LoggingT m a #
MonadTrans ListT |
Methods lift :: Monad m => m a -> ListT m a #
MonadTrans ResourceT |
Methods lift :: Monad m => m a -> ResourceT m a #
Monoid w => MonadTrans (WriterT w) |
Methods lift :: Monad m => m a -> WriterT w m a #
Monoid w => MonadTrans (WriterT w) |
Methods lift :: Monad m => m a -> WriterT w m a #
MonadTrans (StateT s) |
Methods lift :: Monad m => m a -> StateT s m a #
MonadTrans (StateT s) |
Methods lift :: Monad m => m a -> StateT s m a #
MonadTrans (ErrorT e) |
Methods lift :: Monad m => m a -> ErrorT e m a #
MonadTrans (ExceptT e) |
Methods lift :: Monad m => m a -> ExceptT e m a #
MonadTrans (IdentityT *) |
Methods lift :: Monad m => m a -> IdentityT * m a #
MonadTrans (WidgetT site) # |
Methods lift :: Monad m => m a -> WidgetT site m a #
MonadTrans (HandlerT site) # |
Methods lift :: Monad m => m a -> HandlerT site m a #
MonadTrans (ReaderT * r) |
Methods lift :: Monad m => m a -> ReaderT * r m a #
MonadTrans (ConduitM i o) |
Methods lift :: Monad m => m a -> ConduitM i o m a #
MonadTrans (ContT * r) |
Methods lift :: Monad m => m a -> ContT * r m a #
Monoid w => MonadTrans (RWST r w s) |
Methods lift :: Monad m => m a -> RWST r w s m a #
Monoid w => MonadTrans (RWST r w s) |
Methods lift :: Monad m => m a -> RWST r w s m a #
MonadTrans (Pipe l i o u) |
Methods lift :: Monad m => m a -> Pipe l i o u m a #

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:

-     liftIO . return = return

-     liftIO (m >>= f) = liftIO m >>= (liftIO . f)

Instances

MonadIO IO |
Methods liftIO :: IO a -> IO a #
MonadIO Acquire |
Methods liftIO :: IO a -> Acquire a #
MonadIO m => MonadIO (MaybeT m) |
Methods liftIO :: IO a -> MaybeT m a #
MonadIO m => MonadIO (CatchT m) |
Methods liftIO :: IO a -> CatchT m a #
MonadIO m => MonadIO (NoLoggingT m) |
Methods liftIO :: IO a -> NoLoggingT m a #
MonadIO m => MonadIO (LoggingT m) |
Methods liftIO :: IO a -> LoggingT m a #
MonadIO m => MonadIO (ListT m) |
Methods liftIO :: IO a -> ListT m a #
MonadIO m => MonadIO (ResourceT m) |
Methods liftIO :: IO a -> ResourceT m a #
(Monoid w, MonadIO m) => MonadIO (WriterT w m) |
Methods liftIO :: IO a -> WriterT w m a #
(Monoid w, MonadIO m) => MonadIO (WriterT w m) |
Methods liftIO :: IO a -> WriterT w m a #
MonadIO m => MonadIO (StateT s m) |
Methods liftIO :: IO a -> StateT s m a #
MonadIO m => MonadIO (StateT s m) |
Methods liftIO :: IO a -> StateT s m a #
(Error e, MonadIO m) => MonadIO (ErrorT e m) |
Methods liftIO :: IO a -> ErrorT e m a #
MonadIO m => MonadIO (ExceptT e m) |
Methods liftIO :: IO a -> ExceptT e m a #
MonadIO m => MonadIO (IdentityT * m) |
Methods liftIO :: IO a -> IdentityT * m a #
MonadIO m => MonadIO (WidgetT site m) # |
Methods liftIO :: IO a -> WidgetT site m a #
MonadIO m => MonadIO (HandlerT site m) # |
Methods liftIO :: IO a -> HandlerT site m a #
MonadIO m => MonadIO (ReaderT * r m) |
Methods liftIO :: IO a -> ReaderT * r m a #
MonadIO m => MonadIO (ConduitM i o m) |
Methods liftIO :: IO a -> ConduitM i o m a #
MonadIO m => MonadIO (ContT * r m) |
Methods liftIO :: IO a -> ContT * r m a #
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) |
Methods liftIO :: IO a -> RWST r w s m a #
(Monoid w, MonadIO m) => MonadIO (RWST r w s m) |
Methods liftIO :: IO a -> RWST r w s m a #
MonadIO m => MonadIO (Pipe l i o u m) |
Methods liftIO :: IO a -> Pipe l i o u m a #

class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b where #

Instances

MonadBase [] [] |
Methods liftBase :: [α] -> [α] #
MonadBase Maybe Maybe |
Methods liftBase :: Maybe α -> Maybe α #
MonadBase IO IO |
Methods liftBase :: IO α -> IO α #
MonadBase IO Acquire |
Methods liftBase :: IO α -> Acquire α #
MonadBase Identity Identity |
Methods liftBase :: Identity α -> Identity α #
MonadBase STM STM |
Methods liftBase :: STM α -> STM α #
MonadBase b m => MonadBase b (ResourceT m) |
Methods liftBase :: b α -> ResourceT m α #
MonadBase b m => MonadBase b (NoLoggingT m) |
Methods liftBase :: b α -> NoLoggingT m α #
MonadBase b m => MonadBase b (LoggingT m) |
Methods liftBase :: b α -> LoggingT m α #
MonadBase b m => MonadBase b (MaybeT m) |
Methods liftBase :: b α -> MaybeT m α #
MonadBase b m => MonadBase b (ListT m) |
Methods liftBase :: b α -> ListT m α #
(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) |
Methods liftBase :: b α -> WriterT w m α #
(Monoid w, MonadBase b m) => MonadBase b (WriterT w m) |
Methods liftBase :: b α -> WriterT w m α #
MonadBase b m => MonadBase b (StateT s m) |
Methods liftBase :: b α -> StateT s m α #
MonadBase b m => MonadBase b (StateT s m) |
Methods liftBase :: b α -> StateT s m α #
MonadBase b m => MonadBase b (IdentityT * m) |
Methods liftBase :: b α -> IdentityT * m α #
MonadBase b m => MonadBase b (ExceptT e m) |
Methods liftBase :: b α -> ExceptT e m α #
(Error e, MonadBase b m) => MonadBase b (ErrorT e m) |
Methods liftBase :: b α -> ErrorT e m α #
MonadBase b m => MonadBase b (HandlerT site m) # |
Methods liftBase :: b α -> HandlerT site m α #
MonadBase b m => MonadBase b (WidgetT site m) # |
Methods liftBase :: b α -> WidgetT site m α #
MonadBase base m => MonadBase base (ConduitM i o m) |
Methods liftBase :: base α -> ConduitM i o m α #
MonadBase b m => MonadBase b (ReaderT * r m) |
Methods liftBase :: b α -> ReaderT * r m α #
MonadBase b m => MonadBase b (ContT * r m) |
Methods liftBase :: b α -> ContT * r m α #
(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) |
Methods liftBase :: b α -> RWST r w s m α #
(Monoid w, MonadBase b m) => MonadBase b (RWST r w s m) |
Methods liftBase :: b α -> RWST r w s m α #
MonadBase base m => MonadBase base (Pipe l i o u m) |
Methods liftBase :: base α -> Pipe l i o u m α #
MonadBase ((->) r) ((->) r) |
Methods liftBase :: (r -> α) -> r -> α #
MonadBase (Either e) (Either e) |
Methods liftBase :: Either e α -> Either e α #
MonadBase (ST s) (ST s) |
Methods liftBase :: ST s α -> ST s α #
MonadBase (ST s) (ST s) |
Methods liftBase :: ST s α -> ST s α #

class MonadBase b m => MonadBaseControl b m | m -> b #

Minimal complete definition

liftBaseWith, restoreM

Instances

MonadBaseControl [] [] |
Associated Types type StM ([] :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase [] [] -> [a]) -> [a] # restoreM :: StM [] a -> [a] #
MonadBaseControl Maybe Maybe |
Associated Types type StM (Maybe :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase Maybe Maybe -> Maybe a) -> Maybe a # restoreM :: StM Maybe a -> Maybe a #
MonadBaseControl IO IO |
Associated Types type StM (IO :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase IO IO -> IO a) -> IO a # restoreM :: StM IO a -> IO a #
MonadBaseControl Identity Identity |
Associated Types type StM (Identity :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase Identity Identity -> Identity a) -> Identity a # restoreM :: StM Identity a -> Identity a #
MonadBaseControl STM STM |
Associated Types type StM (STM :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase STM STM -> STM a) -> STM a # restoreM :: StM STM a -> STM a #
MonadBaseControl b m => MonadBaseControl b (ResourceT m) |
Associated Types type StM (ResourceT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ResourceT m) b -> b a) -> ResourceT m a # restoreM :: StM (ResourceT m) a -> ResourceT m a #
MonadBaseControl b m => MonadBaseControl b (MaybeT m) |
Associated Types type StM (MaybeT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (MaybeT m) b -> b a) -> MaybeT m a # restoreM :: StM (MaybeT m) a -> MaybeT m a #
MonadBaseControl b m => MonadBaseControl b (ListT m) |
Associated Types type StM (ListT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ListT m) b -> b a) -> ListT m a # restoreM :: StM (ListT m) a -> ListT m a #
MonadBaseControl b m => MonadBaseControl b (NoLoggingT m) |
Associated Types type StM (NoLoggingT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (NoLoggingT m) b -> b a) -> NoLoggingT m a # restoreM :: StM (NoLoggingT m) a -> NoLoggingT m a #
MonadBaseControl b m => MonadBaseControl b (LoggingT m) |
Associated Types type StM (LoggingT m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (LoggingT m) b -> b a) -> LoggingT m a # restoreM :: StM (LoggingT m) a -> LoggingT m a #
(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) |
Associated Types type StM (WriterT w m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a # restoreM :: StM (WriterT w m) a -> WriterT w m a #
(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m) |
Associated Types type StM (WriterT w m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (WriterT w m) b -> b a) -> WriterT w m a # restoreM :: StM (WriterT w m) a -> WriterT w m a #
MonadBaseControl b m => MonadBaseControl b (StateT s m) |
Associated Types type StM (StateT s m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a # restoreM :: StM (StateT s m) a -> StateT s m a #
MonadBaseControl b m => MonadBaseControl b (StateT s m) |
Associated Types type StM (StateT s m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (StateT s m) b -> b a) -> StateT s m a # restoreM :: StM (StateT s m) a -> StateT s m a #
MonadBaseControl b m => MonadBaseControl b (IdentityT * m) |
Associated Types type StM (IdentityT * m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (IdentityT * m) b -> b a) -> IdentityT * m a # restoreM :: StM (IdentityT * m) a -> IdentityT * m a #
MonadBaseControl b m => MonadBaseControl b (ExceptT e m) |
Associated Types type StM (ExceptT e m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ExceptT e m) b -> b a) -> ExceptT e m a # restoreM :: StM (ExceptT e m) a -> ExceptT e m a #
(Error e, MonadBaseControl b m) => MonadBaseControl b (ErrorT e m) |
Associated Types type StM (ErrorT e m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ErrorT e m) b -> b a) -> ErrorT e m a # restoreM :: StM (ErrorT e m) a -> ErrorT e m a #
MonadBaseControl b m => MonadBaseControl b (HandlerT site m) # | Note: although we provide a `MonadBaseControl` instance, `lifted-base`'s `fork` function is incompatible with the underlying `ResourceT` system. Instead, if you must fork a separate thread, you should use `resourceForkIO`. Using fork usually leads to an exception that says "Control.Monad.Trans.Resource.register': The mutable state is being accessed after cleanup. Please contact the maintainers."
Associated Types type StM (HandlerT site m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (HandlerT site m) b -> b a) -> HandlerT site m a # restoreM :: StM (HandlerT site m) a -> HandlerT site m a #
MonadBaseControl b m => MonadBaseControl b (WidgetT site m) # |
Associated Types type StM (WidgetT site m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (WidgetT site m) b -> b a) -> WidgetT site m a # restoreM :: StM (WidgetT site m) a -> WidgetT site m a #
MonadBaseControl b m => MonadBaseControl b (ReaderT * r m) |
Associated Types type StM (ReaderT * r m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ReaderT * r m) b -> b a) -> ReaderT * r m a # restoreM :: StM (ReaderT * r m) a -> ReaderT * r m a #
(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) |
Associated Types type StM (RWST r w s m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a # restoreM :: StM (RWST r w s m) a -> RWST r w s m a #
(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m) |
Associated Types type StM (RWST r w s m :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (RWST r w s m) b -> b a) -> RWST r w s m a # restoreM :: StM (RWST r w s m) a -> RWST r w s m a #
MonadBaseControl ((->) r) ((->) r) |
Associated Types type StM ((->) r :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase ((->) r) ((->) r) -> r -> a) -> r -> a # restoreM :: StM ((->) r) a -> r -> a #
MonadBaseControl (Either e) (Either e) |
Associated Types type StM (Either e :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (Either e) (Either e) -> Either e a) -> Either e a # restoreM :: StM (Either e) a -> Either e a #
MonadBaseControl (ST s) (ST s) |
Associated Types type StM (ST s :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a # restoreM :: StM (ST s) a -> ST s a #
MonadBaseControl (ST s) (ST s) |
Associated Types type StM (ST s :: * -> *) a :: * # Methods liftBaseWith :: (RunInBase (ST s) (ST s) -> ST s a) -> ST s a # restoreM :: StM (ST s) a -> ST s a #

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

Instances

MonadResource m => MonadResource (MaybeT m) |
Methods liftResourceT :: ResourceT IO a -> MaybeT m a #
MonadResource m => MonadResource (NoLoggingT m) |
Methods liftResourceT :: ResourceT IO a -> NoLoggingT m a #
MonadResource m => MonadResource (LoggingT m) |
Methods liftResourceT :: ResourceT IO a -> LoggingT m a #
MonadResource m => MonadResource (ListT m) |
Methods liftResourceT :: ResourceT IO a -> ListT m a #
(MonadThrow m, MonadBase IO m, MonadIO m, Applicative m) => MonadResource (ResourceT m) |
Methods liftResourceT :: ResourceT IO a -> ResourceT m a #
(Monoid w, MonadResource m) => MonadResource (WriterT w m) |
Methods liftResourceT :: ResourceT IO a -> WriterT w m a #
(Monoid w, MonadResource m) => MonadResource (WriterT w m) |
Methods liftResourceT :: ResourceT IO a -> WriterT w m a #
MonadResource m => MonadResource (StateT s m) |
Methods liftResourceT :: ResourceT IO a -> StateT s m a #
MonadResource m => MonadResource (StateT s m) |
Methods liftResourceT :: ResourceT IO a -> StateT s m a #
(Error e, MonadResource m) => MonadResource (ErrorT e m) |
Methods liftResourceT :: ResourceT IO a -> ErrorT e m a #
MonadResource m => MonadResource (ExceptT e m) |
Methods liftResourceT :: ResourceT IO a -> ExceptT e m a #
MonadResource m => MonadResource (IdentityT * m) |
Methods liftResourceT :: ResourceT IO a -> IdentityT * m a #
(Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (WidgetT site m) # |
Methods liftResourceT :: ResourceT IO a -> WidgetT site m a #
(MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (HandlerT site m) # |
Methods liftResourceT :: ResourceT IO a -> HandlerT site m a #
MonadResource m => MonadResource (ReaderT * r m) |
Methods liftResourceT :: ResourceT IO a -> ReaderT * r m a #
MonadResource m => MonadResource (ConduitM i o m) |
Methods liftResourceT :: ResourceT IO a -> ConduitM i o m a #
MonadResource m => MonadResource (ContT * r m) |
Methods liftResourceT :: ResourceT IO a -> ContT * r m a #
(Monoid w, MonadResource m) => MonadResource (RWST r w s m) |
Methods liftResourceT :: ResourceT IO a -> RWST r w s m a #
(Monoid w, MonadResource m) => MonadResource (RWST r w s m) |
Methods liftResourceT :: ResourceT IO a -> RWST r w s m a #
MonadResource m => MonadResource (Pipe l i o u m) |
Methods liftResourceT :: ResourceT IO a -> Pipe l i o u m a #

class Monad m => MonadLogger m #

A `Monad` which has the ability to log messages in some manner.

Instances

MonadLogger m => MonadLogger (MaybeT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> MaybeT m () #
Monad m => MonadLogger (NoLoggingT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> NoLoggingT m () #
MonadIO m => MonadLogger (LoggingT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> LoggingT m () #
MonadLogger m => MonadLogger (ListT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ListT m () #
MonadLogger m => MonadLogger (ResourceT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ResourceT m () #
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #
(MonadLogger m, Monoid w) => MonadLogger (WriterT w m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WriterT w m () #
MonadLogger m => MonadLogger (StateT s m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #
MonadLogger m => MonadLogger (StateT s m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> StateT s m () #
(MonadLogger m, Error e) => MonadLogger (ErrorT e m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ErrorT e m () #
MonadLogger m => MonadLogger (ExceptT e m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ExceptT e m () #
MonadLogger m => MonadLogger (IdentityT * m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> IdentityT * m () #
MonadIO m => MonadLogger (WidgetT site m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WidgetT site m () #
MonadIO m => MonadLogger (HandlerT site m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> HandlerT site m () #
MonadLogger m => MonadLogger (ReaderT * r m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ReaderT * r m () #
MonadLogger m => MonadLogger (ConduitM i o m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ConduitM i o m () #
MonadLogger m => MonadLogger (ContT * r m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ContT * r m () #
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #
(MonadLogger m, Monoid w) => MonadLogger (RWST r w s m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> RWST r w s m () #
MonadLogger m => MonadLogger (Pipe l i o u m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> 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 #

readIntegral :: Num a => String -> Maybe a #

# Shakespeare

## Hamlet

hamlet :: QuasiQuoter #

Hamlet quasi-quoter. May only be used to generate expressions.

Generated expression have type ``HtmlUrl` url`, for some `url`.

    data MyRoute = Home

    render :: Render MyRoute
    render Home _ = "/home"

    >>> putStrLn (renderHtml ([hamlet|<a href=@{Home}>Home|] render))
    <a href="/home">Home</a>

shamlet :: QuasiQuoter #

"Simple Hamlet" quasi-quoter. May only be used to generate expressions.

Generated expressions have type `Html`.

    >>> putStrLn (renderHtml [shamlet|<div>Hello, world!|])
    <div>Hello, world!</div>

xhamlet :: QuasiQuoter #

Like `hamlet`, but produces XHTML.

type HtmlUrl url = Render url -> Html #

A function generating an `Html` given a URL-rendering function.

## Julius

julius :: QuasiQuoter #

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

cassius :: QuasiQuoter #

lucius :: QuasiQuoter #

    >>> renderCss ([lucius|foo{bar:baz}|] undefined)
    "foo{bar:baz}"

type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css #

renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text #