-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Functional reactive web framework
--
-- Web framework based on the design pattern of functional reactive
-- programming (FRP) using the netwire library.
@package webwire
@version 0.1.0
-- | HTML widgets, inspired by Yesod.
module WebWire.Widget
-- | A widget is essentially a full HTML page splitted into the actual HTML
-- markup and its dependencies like CSS and JavaScript.
data Widget
Widget :: Html -> [Text] -> [Text] -> [Text] -> [Text] -> [Text] -> Widget
-- | HTML body.
wgtBody :: Widget -> Html
-- | CSS source code to add.
wgtHeadCSS :: Widget -> [Text]
-- | JavaScript source code to add.
wgtHeadJS :: Widget -> [Text]
-- | CSS links to add.
wgtLinkCSS :: Widget -> [Text]
-- | JavaScript links to add.
wgtLinkJS :: Widget -> [Text]
-- | Page title parts.
wgtTitle :: Widget -> [Text]
-- | Widget with an HTML body fragment.
bodyW :: Html -> Widget
-- | Widget with an HTML body fragment from Hamlet.
hamletW :: HtmlUrl a -> Widget
-- | Widget with a title segment.
titleW :: Text -> Widget
-- | Widget with an inline CSS stylesheet rendered by Cassius or Lucius.
cassiusW :: CssUrl a -> Widget
-- | Widget with an external CSS link.
cssLinkW :: Text -> Widget
-- | Widget with an inline CSS stylesheet.
cssW :: Text -> Widget
-- | Widget with an external JavaScript link.
jsLinkW :: Text -> Widget
-- | Widget with inline JavaScript.
jsW :: Text -> Widget
-- | Widget with inline JavaScript rendered by Julius.
juliusW :: JavascriptUrl a -> Widget
instance ToHtml Widget
instance Monoid Widget
-- | Types used in webwire.
module WebWire.Types
-- | A web exception is an HTTP status code possibly with additional data.
data WebException
-- | Generic web exception. This can be an internal server error (5xx) or
-- document error (4xx), which don't need additional data.
WebException :: Status -> WebException
-- | Redirection exception. The second argument specifies the URI to
-- redirect to.
WebRedirect :: Status -> Text -> WebException
-- | Various output types. The boolean argument taken by the constructors
-- specifies whether a Content-length header should be sent. If true, the
-- string will be fully built, before being sent to the client.
data WebOutput
-- | Generic data output
GenOutput :: Bool -> Ascii -> Builder -> WebOutput
-- | UTF-8-encoded HTML.
HtmlOutput :: Bool -> Html -> WebOutput
-- | UTF-8-encoded string.
TextOutput :: Bool -> Builder -> WebOutput
-- | Web request handling wires.
type WebWire site = Wire (StateT (WebConfig site) IO)
-- | Types of redirection. For temporary redirections, especially in
-- response to handling a form, you will want to use
-- RedirectSeeOther.
data RedirectType
-- | Permanently moved (301).
RedirectPermanent :: RedirectType
-- | See other (303).
RedirectSeeOther :: RedirectType
-- | Temporary redirection (307).
RedirectTemporary :: RedirectType
-- | Wire type for simple sites.
type SimpleWire = WebWire ()
-- | Runtime configuration of a wire.
data WebConfig site
WebConfig :: Map ByteString ByteString -> [Text] -> Map ByteString ByteString -> Map ByteString (FileInfo FilePath) -> Map ByteString ByteString -> Request -> [Text] -> [Text] -> Map ByteString ByteString -> [(CI Ascii, Ascii)] -> site -> Widget -> WebConfig site
-- | Received cookies.
wcCookies :: WebConfig site -> Map ByteString ByteString
-- | Current path.
wcCurrentPath :: WebConfig site -> [Text]
-- | POST parameters.
wcPostParams :: WebConfig site -> Map ByteString ByteString
-- | POST files.
wcPostFiles :: WebConfig site -> Map ByteString (FileInfo FilePath)
-- | Query parameters.
wcQueryParams :: WebConfig site -> Map ByteString ByteString
-- | Current request.
wcRequest :: WebConfig site -> Request
-- | Request path.
wcRequestPath :: WebConfig site -> [Text]
-- | Site's root path.
wcRootPath :: WebConfig site -> [Text]
-- | Cookies to add to the response.
wcSetCookies :: WebConfig site -> Map ByteString ByteString
-- | Headers to add to the response.
wcSetHeaders :: WebConfig site -> [(CI Ascii, Ascii)]
-- | User site argument.
wcSite :: WebConfig site -> site
-- | Default rendering widget.
wcWidget :: WebConfig site -> Widget
instance Typeable WebException
instance Exception WebException
instance Show WebException
-- | Various webwire tools.
module WebWire.Tools
-- | Retrieve the given query parameter. Inhibits with 404, if the
-- parameter does not exist.
getQueryParam :: WebWire site ByteString ByteString
-- | Add an additional header to the response.
addHeader :: WebWire site (CI Ascii, Ascii) ()
-- | Retrieves the given cookie from the request. Inhibits, if the cookie
-- doesn't exist.
getCookie :: WebWire site ByteString ByteString
-- | Sets the given cookie.
setCookie :: WebWire site SetCookie ()
-- | Sets the given cookie for the root path of the current domain with the
-- given validity duration. If no duration is given, it becomes a session
-- cookie.
setCookieSimple :: WebWire site (ByteString, ByteString, Maybe NominalDiffTime) ()
-- | Inhibits with a 404 error.
notFound :: WebWire site a b
-- | Reactive web session handling.
module WebWire.Session
-- | Session configuration.
data SessionCfg
SessionCfg :: Maybe NominalDiffTime -> Int -> Time -> SessionCfg
-- | Validity duration of the session cookies.
sessDuration :: SessionCfg -> Maybe NominalDiffTime
-- | Threshold of saved sessions, after which sessions can be deleted.
sessThreshold :: SessionCfg -> Int
-- | Minimum validitity time. Younger sessions won't be killed on the
-- server side.
sessTimeLimit :: SessionCfg -> Time
-- | Session identifiers.
type WebSession = ByteString
-- | Default session configuration.
defSessionCfg :: SessionCfg
-- | Reactive session handling. The given wire is evolved for each user
-- session individually.
session :: SessionCfg -> WebWire site (WebSession, a) b -> WebWire site a b
-- | Get the current session id. Inhibits, if the client didn't have one.
getSessId :: WebWire site (Maybe NominalDiffTime) WebSession
-- | Generate a new session id and sends a cookie to the client. The input
-- signal specifies the validity duration. If Nothing, then the
-- session is valid for the duration of the browser session.
setNewSessId :: WebWire site (Maybe NominalDiffTime) ByteString
-- | Routing functionality.
module WebWire.Routing
-- | If the request root segment is the given directory, then removes the
-- root segment and adds it to the current path for the given wire.
directory :: Text -> WebWire site a b -> WebWire site a b
-- | If the request root segment is the given file and there are no more
-- segments, then removes the last segment and adds it to the current
-- path for the given wire.
file :: Text -> WebWire site a b -> WebWire site a b
-- | Run the given wire, if the current request path is empty. Otherwise
-- inhibit with 404.
rootDir :: WebWire site a b -> WebWire site a b
-- | Redirect to the input URI. Inhibits with the appropriate exception.
redirect :: RedirectType -> WebWire site Text b
-- | Redirect to the input URI. Inhibits with the appropriate exception.
redirectRaw :: RedirectType -> WebWire site Text b
-- | Convenience interface to redirect for the very common 303
-- redirection.
seeOther :: WebWire site Text b
-- | Convenience interface to redirect for the very common 303
-- redirection.
seeOtherRaw :: WebWire site Text b
-- | Remove the root request segment and add it to the current path.
-- Inhibits with a 404 error, if the request path is empty.
cdIn :: WebWire site a ()
-- | Remove the current tail segment and add it to the request path.
-- Inhibits with a 404 error, if the current path is empty.
cdOut :: WebWire site a ()
-- | Output the current path segment, if there is one. Outputs
-- Nothing, if there are no further path segments. In particular,
-- if the root path is requested, this wire always returns
-- Nothing.
currentDir :: WebWire site a (Maybe Text)
-- | Output the current rest of the path segment.
currentPath :: WebWire site a [Text]
-- | Construct the full URI to the given path from the root path.
pathAbs :: WebWire site [Text] Text
-- | Construct the full URI to the given path from the current path.
pathRel :: WebWire site [Text] Text
-- | Output the root request path segment, if there is one. Outputs
-- Nothing, if there are no further path segments. In particular,
-- if the root path is requested, this wire always returns
-- Nothing.
requestDir :: WebWire site a (Maybe Text)
-- | Output the rest of the request path segment.
requestPath :: WebWire site a [Text]
-- | Output the current root path.
rootPath :: WebWire site a [Text]
-- | Set the current root path. This wire also resets the current path.
setRoot :: WebWire site [Text] ()
-- | Rendering module.
module WebWire.Render
-- | This class represents renderable types. Each renderable type can
-- support rendering to several target representations like HTML, JSON,
-- XML, etc.
--
-- For simple applications the predefined instances should suffice.
class Renderable src
toWebOutput :: Renderable src => WebWire site src WebOutput
toWebOutputGen :: Renderable src => WebWire site src WebOutput
toWebOutputHtml :: Renderable src => WebWire site src WebOutput
toWebOutputPlain :: Renderable src => WebWire site src WebOutput
-- | Render the given renderable value as a response to the user.
render :: Renderable src => WebWire site src Response
-- | Render the given output as a response to the user.
respondOutput :: WebWire site WebOutput Response
-- | Add the input widget to the current default widget.
addWidget :: WebWire site Widget ()
-- | Render the default widget.
renderDef :: WebWire site a Response
instance Renderable Widget
instance Renderable Text
instance Renderable String
instance Renderable Javascript
instance Renderable Html
instance Renderable Css
instance Renderable ByteString
-- | Core functionality.
module WebWire.Core
-- | Run a webwire application using the given WAI handler.
webWire :: (Application -> IO a) -> site -> WebWire site () Response -> IO a
-- | Run a simple webwire. This wire type is for simple sites (usually just
-- test sites or temporary sites), which don't need a custom
-- WebSite instance.
simpleWire :: (Application -> IO a) -> SimpleWire () Response -> IO a
-- | Present a very simple plaintext error page for the given status.
simpleError :: WebWire site Status Response
-- | Convenience module.
module WebWire