Yesod.Core.Types

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

Safe Haskell | None
Language | Haskell98

Yesod.Core.Types

Synopsis

- type SessionMap = Map Text ByteString
- type SaveSession = SessionMap -> IO [Header]
- newtype SessionBackend = SessionBackend {
  - sbLoadSession :: Request -> IO (SessionMap, SaveSession)
  }
- data SessionCookie = SessionCookie (Either UTCTime ByteString) ByteString SessionMap
- data ClientSessionDateCache = ClientSessionDateCache {
  - csdcNow :: !UTCTime
  - csdcExpires :: !UTCTime
  - csdcExpiresSerialized :: !ByteString
  }
- data YesodRequest = YesodRequest {
  - reqGetParams :: ![(Text, Text)]
  - reqCookies :: ![(Text, Text)]
  - reqWaiRequest :: !Request
  - reqLangs :: ![Text]
  - reqToken :: !(Maybe Text)
  - reqSession :: !SessionMap
  - reqAccept :: ![ContentType]
  }
- data YesodResponse
  - = YRWai !Response
  - | YRWaiApp !Application
  - | YRPlain !Status ![Header] !ContentType !Content !SessionMap
- type RequestBodyContents = ([(Text, Text)], [(Text, FileInfo)])
- data FileInfo = FileInfo {
  - fileName :: !Text
  - fileContentType :: !Text
  - fileSourceRaw :: !(Source (ResourceT IO) ByteString)
  - fileMove :: !(FilePath -> IO ())
  }
- data FileUpload
  - = FileUploadMemory !(BackEnd ByteString)
  - | FileUploadDisk !(InternalState -> BackEnd FilePath)
  - | FileUploadSource !(BackEnd (Source (ResourceT IO) ByteString))
- data Approot master
  - = ApprootRelative
  - | ApprootStatic !Text
  - | ApprootMaster !(master -> Text)
  - | ApprootRequest !(master -> Request -> Text)
- type ResolvedApproot = Text
- data AuthResult
  - = Authorized
  - | AuthenticationRequired
  - | Unauthorized Text
- data ScriptLoadPosition master
  - = BottomOfBody
  - | BottomOfHeadBlocking
  - | BottomOfHeadAsync (BottomOfHeadAsync master)
- type BottomOfHeadAsync master = [Text] -> Maybe (HtmlUrl (Route master)) -> HtmlUrl (Route master)
- type Texts = [Text]
- newtype WaiSubsite = WaiSubsite {
  - runWaiSubsite :: Application
  }
- data RunHandlerEnv site = RunHandlerEnv {
  - rheRender :: !(Route site -> [(Text, Text)] -> Text)
  - rheRoute :: !(Maybe (Route site))
  - rheSite :: !site
  - rheUpload :: !(RequestBodyLength -> FileUpload)
  - rheLog :: !(Loc -> LogSource -> LogLevel -> LogStr -> IO ())
  - rheOnError :: !(ErrorResponse -> YesodApp)
  - rheMaxExpires :: !Text
  }
- data HandlerData site parentRoute = HandlerData {
  - handlerRequest :: !YesodRequest
  - handlerEnv :: !(RunHandlerEnv site)
  - handlerState :: !(IORef GHState)
  - handlerToParent :: !(Route site -> parentRoute)
  - handlerResource :: !InternalState
  }
- data YesodRunnerEnv site = YesodRunnerEnv {
  - yreLogger :: !Logger
  - yreSite :: !site
  - yreSessionBackend :: !(Maybe SessionBackend)
  - yreGen :: !GenIO
  - yreGetMaxExpires :: IO Text
  }
- data YesodSubRunnerEnv sub parent parentMonad = YesodSubRunnerEnv {
  - ysreParentRunner :: !(ParentRunner parent parentMonad)
  - ysreGetSub :: !(parent -> sub)
  - ysreToParentRoute :: !(Route sub -> Route parent)
  - ysreParentEnv :: !(YesodRunnerEnv parent)
  }
- type ParentRunner parent m = m TypedContent -> YesodRunnerEnv parent -> Maybe (Route parent) -> Application
- newtype HandlerT site m a = HandlerT {
  - unHandlerT :: HandlerData site (MonadRoute m) -> m a
  }
- type family MonadRoute (m :: * -> *)
- data GHState = GHState {
  - ghsSession :: SessionMap
  - ghsRBC :: Maybe RequestBodyContents
  - ghsIdent :: Int
  - ghsCache :: TypeMap
  - ghsCacheBy :: KeyedTypeMap
  - ghsHeaders :: Endo [Header]
  }
- type YesodApp = YesodRequest -> ResourceT IO YesodResponse
- newtype WidgetT site m a = WidgetT {
  - unWidgetT :: HandlerData site (MonadRoute m) -> m (a, GWData (Route site))
  }
- type RY master = Route master -> [(Text, Text)] -> Text
- newtype CssBuilder = CssBuilder {
  - unCssBuilder :: Builder
  }
- data PageContent url = PageContent {
  - pageTitle :: Html
  - pageHead :: HtmlUrl url
  - pageBody :: HtmlUrl url
  }
- data Content
  - = ContentBuilder !Builder !(Maybe Int)
  - | ContentSource !(Source (ResourceT IO) (Flush Builder))
  - | ContentFile !FilePath !(Maybe FilePart)
  - | ContentDontEvaluate !Content
- data TypedContent = TypedContent !ContentType !Content
- type RepHtml = Html
- newtype RepJson = RepJson Content
- newtype RepPlain = RepPlain Content
- newtype RepXml = RepXml Content
- type ContentType = ByteString
- newtype DontFullyEvaluate a = DontFullyEvaluate {
  - unDontFullyEvaluate :: a
  }
- data ErrorResponse
  - = NotFound
  - | InternalError Text
  - | InvalidArgs [Text]
  - | NotAuthenticated
  - | PermissionDenied Text
  - | BadMethod Method
- data Header
  - = AddCookie SetCookie
  - | DeleteCookie ByteString ByteString
  - | Header ByteString ByteString
- data Location url
  - = Local url
  - | Remote Text
- newtype UniqueList x = UniqueList ([x] -> [x])
- data Script url = Script {
  - scriptLocation :: Location url
  - scriptAttributes :: [(Text, Text)]
  }
- data Stylesheet url = Stylesheet {
  - styleLocation :: Location url
  - styleAttributes :: [(Text, Text)]
  }
- newtype Title = Title {
  - unTitle :: Html
  }
- newtype Head url = Head (HtmlUrl url)
- newtype Body url = Body (HtmlUrl url)
- type CssBuilderUrl a = (a -> [(Text, Text)] -> Text) -> Builder
- data GWData a = GWData {
  - gwdBody :: !(Body a)
  - gwdTitle :: !(Last Title)
  - gwdScripts :: !(UniqueList (Script a))
  - gwdStylesheets :: !(UniqueList (Stylesheet a))
  - gwdCss :: !(Map (Maybe Text) (CssBuilderUrl a))
  - gwdJavascript :: !(Maybe (JavascriptUrl a))
  - gwdHead :: !(Head a)
  }
- data HandlerContents
  - = HCContent Status !TypedContent
  - | HCError ErrorResponse
  - | HCSendFile ContentType FilePath (Maybe FilePart)
  - | HCRedirect Status Text
  - | HCCreated Text
  - | HCWai Response
  - | HCWaiApp Application
- data Logger = Logger {
  - loggerSet :: !LoggerSet
  - loggerDate :: !DateCacheGetter
  }
- loggerPutStr :: Logger -> LogStr -> IO ()

# Documentation

type SessionMap = Map Text ByteString #

type SaveSession #

Arguments

= SessionMap | The session contents after running the handler
-> IO [Header] |

newtype SessionBackend #

Constructors

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

data SessionCookie #

Constructors

SessionCookie (Either UTCTime ByteString) ByteString SessionMap |

Instances

Read SessionCookie # |
Methods readsPrec :: Int -> ReadS SessionCookie # readList :: ReadS [SessionCookie] # readPrec :: ReadPrec SessionCookie # readListPrec :: ReadPrec [SessionCookie] #
Show SessionCookie # |
Methods showsPrec :: Int -> SessionCookie -> ShowS # show :: SessionCookie -> String # showList :: [SessionCookie] -> ShowS #
Serialize SessionCookie # |
Methods put :: Putter SessionCookie # get :: Get SessionCookie #

data ClientSessionDateCache #

Constructors

ClientSessionDateCache |
Fields csdcNow :: !UTCTime csdcExpires :: !UTCTime csdcExpiresSerialized :: !ByteString

Instances

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

data YesodRequest #

The parsed request information. This type augments the standard WAI `Request` with additional information.

Constructors

YesodRequest |
Fields reqGetParams :: ![(Text, Text)] Same as `queryString`, but decoded to `Text`. reqCookies :: ![(Text, Text)] reqWaiRequest :: !Request reqLangs :: ![Text] Languages which the client supports. This is an ordered list by preference. reqToken :: !(Maybe Text) A random, session-specific token used to prevent CSRF attacks. reqSession :: !SessionMap Initial session sent from the client. Since 1.2.0 reqAccept :: ![ContentType] An ordered list of the accepted content types. Since 1.2.0

data YesodResponse #

An augmented WAI `Response`. This can either be a standard `Response`, or a higher-level data structure which Yesod will turn into a `Response`.

Constructors

YRWai !Response |
YRWaiApp !Application |
YRPlain !Status ![Header] !ContentType !Content !SessionMap |

type RequestBodyContents = ([(Text, Text)], [(Text, FileInfo)]) #

A tuple containing both the POST parameters and submitted files.

data FileInfo #

Constructors

FileInfo |
Fields fileName :: !Text fileContentType :: !Text fileSourceRaw :: !(Source (ResourceT IO) ByteString) fileMove :: !(FilePath -> IO ())

data FileUpload #

Constructors

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

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

type ResolvedApproot = Text #

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 #

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

type Texts = [Text] #

newtype WaiSubsite #

Wrap up a normal WAI application as a Yesod subsite.

Constructors

WaiSubsite |
Fields runWaiSubsite :: Application

Instances

ParseRoute WaiSubsite # |
Methods parseRoute :: ([Text], [(Text, Text)]) -> Maybe (Route WaiSubsite) #
RenderRoute WaiSubsite # |
Associated Types data Route WaiSubsite :: * # Methods renderRoute :: Route WaiSubsite -> ([Text], [(Text, Text)]) #
YesodSubDispatch WaiSubsite master # |
Methods yesodSubDispatch :: YesodSubRunnerEnv WaiSubsite (HandlerSite master) master -> Application #
Eq (Route WaiSubsite) # |
Methods (==) :: Route WaiSubsite -> Route WaiSubsite -> Bool # (/=) :: Route WaiSubsite -> Route WaiSubsite -> Bool #
Ord (Route WaiSubsite) # |
Methods compare :: Route WaiSubsite -> Route WaiSubsite -> Ordering # (<) :: Route WaiSubsite -> Route WaiSubsite -> Bool # (<=) :: Route WaiSubsite -> Route WaiSubsite -> Bool # (>) :: Route WaiSubsite -> Route WaiSubsite -> Bool # (>=) :: Route WaiSubsite -> Route WaiSubsite -> Bool # max :: Route WaiSubsite -> Route WaiSubsite -> Route WaiSubsite # min :: Route WaiSubsite -> Route WaiSubsite -> Route WaiSubsite #
Read (Route WaiSubsite) # |
Methods readsPrec :: Int -> ReadS (Route WaiSubsite) # readList :: ReadS [Route WaiSubsite] # readPrec :: ReadPrec (Route WaiSubsite) # readListPrec :: ReadPrec [Route WaiSubsite] #
Show (Route WaiSubsite) # |
Methods showsPrec :: Int -> Route WaiSubsite -> ShowS # show :: Route WaiSubsite -> String # showList :: [Route WaiSubsite] -> ShowS #
data Route WaiSubsite # |
data Route WaiSubsite = WaiSubsiteRoute [Text] [(Text, Text)]

data RunHandlerEnv site #

Constructors

RunHandlerEnv |
Fields rheRender :: !(Route site -> [(Text, Text)] -> Text) rheRoute :: !(Maybe (Route site)) rheSite :: !site rheUpload :: !(RequestBodyLength -> FileUpload) rheLog :: !(Loc -> LogSource -> LogLevel -> LogStr -> IO ()) rheOnError :: !(ErrorResponse -> YesodApp) How to respond when an error is thrown internally. Since 1.2.0 rheMaxExpires :: !Text

data HandlerData site parentRoute #

Constructors

HandlerData |
Fields handlerRequest :: !YesodRequest handlerEnv :: !(RunHandlerEnv site) handlerState :: !(IORef GHState) handlerToParent :: !(Route site -> parentRoute) handlerResource :: !InternalState

data YesodRunnerEnv site #

Constructors

YesodRunnerEnv |
Fields yreLogger :: !Logger yreSite :: !site yreSessionBackend :: !(Maybe SessionBackend) yreGen :: !GenIO yreGetMaxExpires :: IO Text

data YesodSubRunnerEnv sub parent parentMonad #

Constructors

YesodSubRunnerEnv |
Fields ysreParentRunner :: !(ParentRunner parent parentMonad) ysreGetSub :: !(parent -> sub) ysreToParentRoute :: !(Route sub -> Route parent) ysreParentEnv :: !(YesodRunnerEnv parent)

type ParentRunner parent m = m TypedContent -> YesodRunnerEnv parent -> Maybe (Route parent) -> Application #

newtype HandlerT site m a #

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

Constructors

HandlerT |
Fields unHandlerT :: HandlerData site (MonadRoute m) -> m a

Instances

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 #
MonadBase b m => MonadBase b (HandlerT site m) # |
Methods liftBase :: b α -> HandlerT site m α #
Monad m => MonadReader site (HandlerT site m) # |
Methods ask :: HandlerT site m site # local :: (site -> site) -> HandlerT site m a -> HandlerT site m a # reader :: (site -> a) -> HandlerT site m a #
MonadTrans (HandlerT site) # |
Methods lift :: Monad m => m a -> HandlerT site m a #
Monad m => Monad (HandlerT site m) # |
Methods (>>=) :: HandlerT site m a -> (a -> HandlerT site m b) -> HandlerT site m b # (>>) :: HandlerT site m a -> HandlerT site m b -> HandlerT site m b # return :: a -> HandlerT site m a # fail :: String -> HandlerT site m a #
Monad m => Functor (HandlerT site m) # |
Methods fmap :: (a -> b) -> HandlerT site m a -> HandlerT site m b # (<$) :: a -> HandlerT site m b -> HandlerT site m a #
Monad m => Applicative (HandlerT site m) # |
Methods pure :: a -> HandlerT site m a # (<*>) :: HandlerT site m (a -> b) -> HandlerT site m a -> HandlerT site m b # (*>) :: HandlerT site m a -> HandlerT site m b -> HandlerT site m b # (<*) :: HandlerT site m a -> HandlerT site m b -> HandlerT site m a #
MonadIO m => MonadIO (HandlerT site m) # |
Methods liftIO :: IO a -> HandlerT site m a #
MonadActive m => MonadActive (HandlerT site m) # |
Methods monadActive :: HandlerT site m Bool #
MonadThrow m => MonadThrow (HandlerT site m) # |
Methods throwM :: Exception e => e -> HandlerT site m a #
MonadCatch m => MonadCatch (HandlerT site m) # |
Methods catch :: Exception e => HandlerT site m a -> (e -> HandlerT site m a) -> HandlerT site m a #
MonadMask m => MonadMask (HandlerT site m) # |
Methods mask :: ((forall a. HandlerT site m a -> HandlerT site m a) -> HandlerT site m b) -> HandlerT site m b # uninterruptibleMask :: ((forall a. HandlerT site m a -> HandlerT site m a) -> HandlerT site m b) -> HandlerT site m b #
MonadIO m => MonadLogger (HandlerT site m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> HandlerT site m () #
MonadIO m => MonadLoggerIO (HandlerT site m) # |
Methods askLoggerIO :: HandlerT site m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (HandlerT site m) # |
Methods liftResourceT :: ResourceT IO a -> HandlerT 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 #
type MonadRoute (HandlerT site m) # |
type MonadRoute (HandlerT site m) = Route site
type HandlerSite (HandlerT site m) # |
type HandlerSite (HandlerT site m) = site
type StM (HandlerT site m) a # |
type StM (HandlerT site m) a = StM m a

type family MonadRoute (m :: * -> *) #

Instances

type MonadRoute IO # |
type MonadRoute IO = ()
type MonadRoute (HandlerT site m) # |
type MonadRoute (HandlerT site m) = Route site

data GHState #

Constructors

GHState |
Fields ghsSession :: SessionMap ghsRBC :: Maybe RequestBodyContents ghsIdent :: Int ghsCache :: TypeMap ghsCacheBy :: KeyedTypeMap ghsHeaders :: Endo [Header]

type YesodApp = YesodRequest -> ResourceT IO YesodResponse #

An extension of the basic WAI `Application` datatype to provide extra features needed by Yesod. Users should never need to use this directly, as the `HandlerT` monad and template haskell code should hide it away.

newtype WidgetT site m a #

A generic widget, allowing specification of both the subsite and master site datatypes. While this is simply a `WriterT`, we define a newtype for better error messages.

Constructors

WidgetT |
Fields unWidgetT :: HandlerData site (MonadRoute m) -> m (a, GWData (Route site))

Instances

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 #
MonadBase b m => MonadBase b (WidgetT site m) # |
Methods liftBase :: b α -> WidgetT site m α #
Monad m => MonadReader site (WidgetT site m) # |
Methods ask :: WidgetT site m site # local :: (site -> site) -> WidgetT site m a -> WidgetT site m a # reader :: (site -> a) -> WidgetT site m a #
((~) * site' site, (~) (* -> *) IO m, (~) * a ()) => ToWidget site' (WidgetT site m a) # |
Methods toWidget :: (MonadWidget m, (* ~ HandlerSite m) site') => WidgetT site m a -> m () #
MonadTrans (WidgetT site) # |
Methods lift :: Monad m => m a -> WidgetT site m a #
Monad m => Monad (WidgetT site m) # |
Methods (>>=) :: WidgetT site m a -> (a -> WidgetT site m b) -> WidgetT site m b # (>>) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m b # return :: a -> WidgetT site m a # fail :: String -> WidgetT site m a #
Monad m => Functor (WidgetT site m) # |
Methods fmap :: (a -> b) -> WidgetT site m a -> WidgetT site m b # (<$) :: a -> WidgetT site m b -> WidgetT site m a #
Monad m => Applicative (WidgetT site m) # |
Methods pure :: a -> WidgetT site m a # (<*>) :: WidgetT site m (a -> b) -> WidgetT site m a -> WidgetT site m b # (*>) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m b # (<*) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m a #
MonadIO m => MonadIO (WidgetT site m) # |
Methods liftIO :: IO a -> WidgetT site m a #
MonadActive m => MonadActive (WidgetT site m) # |
Methods monadActive :: WidgetT site m Bool #
MonadThrow m => MonadThrow (WidgetT site m) # |
Methods throwM :: Exception e => e -> WidgetT site m a #
MonadCatch m => MonadCatch (WidgetT site m) # |
Methods catch :: Exception e => WidgetT site m a -> (e -> WidgetT site m a) -> WidgetT site m a #
MonadMask m => MonadMask (WidgetT site m) # |
Methods mask :: ((forall a. WidgetT site m a -> WidgetT site m a) -> WidgetT site m b) -> WidgetT site m b # uninterruptibleMask :: ((forall a. WidgetT site m a -> WidgetT site m a) -> WidgetT site m b) -> WidgetT site m b #
MonadIO m => MonadLogger (WidgetT site m) # |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WidgetT site m () #
MonadIO m => MonadLoggerIO (WidgetT site m) # |
Methods askLoggerIO :: WidgetT site m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (WidgetT site m) # |
Methods liftResourceT :: ResourceT IO a -> WidgetT site m a #
MonadResourceBase m => MonadWidget (WidgetT site m) # |
Methods liftWidgetT :: WidgetT (HandlerSite (WidgetT site m)) IO a -> WidgetT site 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 #
(Monad m, (~) * a ()) => IsString (WidgetT site m a) # | A `String` can be trivially promoted to a widget. For example, in a yesod-scaffold site you could use:
    getHomeR = do defaultLayout "Widget text"
Methods fromString :: String -> WidgetT site m a #
((~) * a (), Monad m) => Semigroup (WidgetT site m a) # |
Methods (<>) :: WidgetT site m a -> WidgetT site m a -> WidgetT site m a # sconcat :: NonEmpty (WidgetT site m a) -> WidgetT site m a # stimes :: Integral b => b -> WidgetT site m a -> WidgetT site m a #
((~) * a (), Monad m) => Monoid (WidgetT site m a) # |
Methods mempty :: WidgetT site m a # mappend :: WidgetT site m a -> WidgetT site m a -> WidgetT site m a # mconcat :: [WidgetT site m a] -> WidgetT site m a #
type HandlerSite (WidgetT site m) # |
type HandlerSite (WidgetT site m) = site
type StM (WidgetT site m) a # |
type StM (WidgetT site m) a = StM m (a, GWData (Route site))

type RY master = Route master -> [(Text, Text)] -> Text #

newtype CssBuilder #

Newtype wrapper allowing injection of arbitrary content into CSS.

Usage:

    toWidget $ CssBuilder "p { color: red }"

Since: 1.1.3

Constructors

CssBuilder |
Fields unCssBuilder :: Builder

Instances

ToWidgetHead site CssBuilder # |
Methods toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () #
ToWidgetMedia site CssBuilder # |
Methods toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> CssBuilder -> m () #
ToWidget site CssBuilder # |
Methods toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () #
(~) * render (RY site) => ToWidgetHead site (render -> CssBuilder) # |
Methods toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () #
(~) * render (RY site) => ToWidgetMedia site (render -> CssBuilder) # |
Methods toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> (render -> CssBuilder) -> m () #
(~) * render (RY site) => ToWidget site (render -> CssBuilder) # |
Methods toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () #

data PageContent url #

Content for a web page. By providing this datatype, we can easily create generic site templates, which would have the type signature:

    PageContent url -> HtmlUrl url

Constructors

PageContent |
Fields pageTitle :: Html pageHead :: HtmlUrl url pageBody :: HtmlUrl url

data Content #

Constructors

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

Instances

IsString Content # |
Methods fromString :: String -> Content #
ToContent Content # |
Methods toContent :: Content -> Content #
ToTypedContent (ContentType, Content) # |
Methods toTypedContent :: (ContentType, Content) -> TypedContent #
ToContent (ContentType, Content) # |
Methods toContent :: (ContentType, Content) -> Content #

data TypedContent #

Constructors

TypedContent !ContentType !Content |

Instances

ToTypedContent TypedContent # |
Methods toTypedContent :: TypedContent -> TypedContent #
ToContent TypedContent # |
Methods toContent :: TypedContent -> Content #

type RepHtml = Html #

Deprecated: Please use Html instead

newtype RepJson #

Constructors

RepJson Content |

Instances

ToTypedContent RepJson # |
Methods toTypedContent :: RepJson -> TypedContent #
HasContentType RepJson # |
Methods getContentType :: Monad m => m RepJson -> ContentType #
ToContent RepJson # |
Methods toContent :: RepJson -> Content #

newtype RepPlain #

Constructors

RepPlain Content |

Instances

ToTypedContent RepPlain # |
Methods toTypedContent :: RepPlain -> TypedContent #
HasContentType RepPlain # |
Methods getContentType :: Monad m => m RepPlain -> ContentType #
ToContent RepPlain # |
Methods toContent :: RepPlain -> Content #

newtype RepXml #

Constructors

RepXml Content |

Instances

ToTypedContent RepXml # |
Methods toTypedContent :: RepXml -> TypedContent #
HasContentType RepXml # |
Methods getContentType :: Monad m => m RepXml -> ContentType #
ToContent RepXml # |
Methods toContent :: RepXml -> Content #

type ContentType = ByteString #

newtype DontFullyEvaluate a #

Prevents a response body from being fully evaluated before sending the request.

Since 1.1.0

Constructors

DontFullyEvaluate |
Fields unDontFullyEvaluate :: a

Instances

ToTypedContent a => ToTypedContent (DontFullyEvaluate a) # |
Methods toTypedContent :: DontFullyEvaluate a -> TypedContent #
HasContentType a => HasContentType (DontFullyEvaluate a) # |
Methods getContentType :: Monad m => m (DontFullyEvaluate a) -> ContentType #
ToContent a => ToContent (DontFullyEvaluate a) # |
Methods toContent :: DontFullyEvaluate a -> Content #

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.30-8Yp8hhmqmu58smgiwMgQ4w" 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))))))

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

data Location url #

Constructors

Local url |
Remote Text |

Instances

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

newtype UniqueList x #

A diff list that does not directly enforce uniqueness. When creating a widget Yesod will use nub to make it unique.

Constructors

UniqueList ([x] -> [x]) |

Instances

Semigroup (UniqueList x) # |
Methods (<>) :: UniqueList x -> UniqueList x -> UniqueList x # sconcat :: NonEmpty (UniqueList x) -> UniqueList x # stimes :: Integral b => b -> UniqueList x -> UniqueList x #
Monoid (UniqueList x) # |
Methods mempty :: UniqueList x # mappend :: UniqueList x -> UniqueList x -> UniqueList x # mconcat :: [UniqueList x] -> UniqueList x #

data Script url #

Constructors

Script |
Fields scriptLocation :: Location url scriptAttributes :: [(Text, Text)]

Instances

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

data Stylesheet url #

Constructors

Stylesheet |
Fields styleLocation :: Location url styleAttributes :: [(Text, Text)]

Instances

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

newtype Title #

Constructors

Title |
Fields unTitle :: Html

newtype Head url #

Constructors

Head (HtmlUrl url) |

Instances

Semigroup (Head a) # |
Methods (<>) :: Head a -> Head a -> Head a # sconcat :: NonEmpty (Head a) -> Head a # stimes :: Integral b => b -> Head a -> Head a #
Monoid (Head url) # |
Methods mempty :: Head url # mappend :: Head url -> Head url -> Head url # mconcat :: [Head url] -> Head url #

newtype Body url #

Constructors

Body (HtmlUrl url) |

Instances

Semigroup (Body a) # |
Methods (<>) :: Body a -> Body a -> Body a # sconcat :: NonEmpty (Body a) -> Body a # stimes :: Integral b => b -> Body a -> Body a #
Monoid (Body url) # |
Methods mempty :: Body url # mappend :: Body url -> Body url -> Body url # mconcat :: [Body url] -> Body url #

type CssBuilderUrl a = (a -> [(Text, Text)] -> Text) -> Builder #

data GWData a #

Constructors

GWData |
Fields gwdBody :: !(Body a) gwdTitle :: !(Last Title) gwdScripts :: !(UniqueList (Script a)) gwdStylesheets :: !(UniqueList (Stylesheet a)) gwdCss :: !(Map (Maybe Text) (CssBuilderUrl a)) gwdJavascript :: !(Maybe (JavascriptUrl a)) gwdHead :: !(Head a)

Instances

Semigroup (GWData a) # |
Methods (<>) :: GWData a -> GWData a -> GWData a # sconcat :: NonEmpty (GWData a) -> GWData a # stimes :: Integral b => b -> GWData a -> GWData a #
Monoid (GWData a) # |
Methods mempty :: GWData a # mappend :: GWData a -> GWData a -> GWData a # mconcat :: [GWData a] -> GWData a #

data HandlerContents #

Constructors

HCContent Status !TypedContent |
HCError ErrorResponse |
HCSendFile ContentType FilePath (Maybe FilePart) |
HCRedirect Status Text |
HCCreated Text |
HCWai Response |
HCWaiApp Application |

Instances

Show HandlerContents # |
Methods showsPrec :: Int -> HandlerContents -> ShowS # show :: HandlerContents -> String # showList :: [HandlerContents] -> ShowS #
Exception HandlerContents # |
Methods toException :: HandlerContents -> SomeException # fromException :: SomeException -> Maybe HandlerContents # displayException :: HandlerContents -> String #

data Logger #

Constructors

Logger |
Fields loggerSet :: !LoggerSet loggerDate :: !DateCacheGetter

loggerPutStr :: Logger -> LogStr -> IO () #