snap -package:lsp

Top-level package for the Snap Web Framework This is the top-level package for the official Snap Framework libraries. It includes:
  • The Snaplets API
  • Snaplets for sessions, authentication, and templates
To get started, issue the following sequence of commands:
$ cabal install snap snap-templates
$ mkdir myproject
$ cd myproject
$ snap init
If you have trouble or any questions, see our FAQ page (http://snapframework.com/faq) or the documentation (http://snapframework.com/docs). Note: since version 1.0, the "snap" executable program for generating starter projects is provided by the snap-templates package.
Event source with a single occurrence at time 0. The value of the event is obtained by sampling the input at that time.
Snap is the Monad that user web handlers run in. Snap gives you:
  1. Stateful access to fetch or modify an HTTP Request.
    printRqContextPath :: Snap () printRqContextPath =
    writeBS . rqContextPath =<< getRequest
    
  2. Stateful access to fetch or modify an HTTP Response.
    printRspStatusReason :: Snap ()
    printRspStatusReason = writeBS . rspStatusReason
    =<< getResponse 
  3. Failure / Alternative / MonadPlus semantics: a Snap handler can choose not to handle a given request, using empty or its synonym pass, and you can try alternative handlers with the <|> operator:
    a :: Snap String a =
    pass b :: Snap String b = return "foo" c :: Snap String c = a
    <|> b -- try running a, if it fails then try b
    
  4. Convenience functions (writeBS, writeLBS, writeText, writeLazyText, addToOutput) for queueing output to be written to the Response, or for streaming to the response using io-streams:
    example ::
    (OutputStream Builder -> IO (OutputStream
    Builder)) -> Snap () example streamProc = do writeBS
    "I'm a strict bytestring" writeLBS "I'm a lazy bytestring"
    writeText "I'm strict text" addToOutput streamProc
    
  5. Early termination: if you call finishWith:
    a :: Snap ()
    a = do modifyResponse $ setResponseStatus 500 "Internal
    Server Error" writeBS "500 error" r <- getResponse
    finishWith r 
    then any subsequent processing will be skipped and the supplied Response value will be returned from runSnap as-is.
  6. Access to the IO monad through a MonadIO instance:
    a :: Snap () a = liftIO fireTheMissiles
    
  7. The ability to set or extend a timeout which will kill the handler thread after N seconds of inactivity (the default is 20 seconds):
    a :: Snap () a = setTimeout 30 
  8. Throw and catch exceptions using a MonadBaseControl instance:
    import Control.Exception.Lifted
    (SomeException, throwIO, catch) foo :: Snap ()
    foo = bar `catch` (e::SomeException) -> baz where bar =
    throwIO FooException 
  9. Log a message to the error log:
    foo :: Snap () foo =
    logError "grumble." 
You may notice that most of the type signatures in this module contain a (MonadSnap m) => ... typeclass constraint. MonadSnap is a typeclass which, in essence, says "you can get back to the Snap monad from here". Using MonadSnap you can extend the Snap monad with additional functionality and still have access to most of the Snap functions without writing lift everywhere. Instances are already provided for most of the common monad transformers (ReaderT, WriterT, StateT, etc.).
Snap is the Monad that user web handlers run in. Snap gives you:
  1. Stateful access to fetch or modify an HTTP Request.
    printRqContextPath :: Snap () printRqContextPath =
    writeBS . rqContextPath =<< getRequest
    
  2. Stateful access to fetch or modify an HTTP Response.
    printRspStatusReason :: Snap ()
    printRspStatusReason = writeBS . rspStatusReason
    =<< getResponse 
  3. Failure / Alternative / MonadPlus semantics: a Snap handler can choose not to handle a given request, using empty or its synonym pass, and you can try alternative handlers with the <|> operator:
    a :: Snap String a =
    pass b :: Snap String b = return "foo" c :: Snap String c = a
    <|> b -- try running a, if it fails then try b
    
  4. Convenience functions (writeBS, writeLBS, writeText, writeLazyText, addToOutput) for queueing output to be written to the Response, or for streaming to the response using io-streams:
    example ::
    (OutputStream Builder -> IO (OutputStream
    Builder)) -> Snap () example streamProc = do writeBS
    "I'm a strict bytestring" writeLBS "I'm a lazy bytestring"
    writeText "I'm strict text" addToOutput streamProc
    
  5. Early termination: if you call finishWith:
    a :: Snap ()
    a = do modifyResponse $ setResponseStatus 500 "Internal
    Server Error" writeBS "500 error" r <- getResponse
    finishWith r 
    then any subsequent processing will be skipped and the supplied Response value will be returned from runSnap as-is.
  6. Access to the IO monad through a MonadIO instance:
    a :: Snap () a = liftIO fireTheMissiles
    
  7. The ability to set or extend a timeout which will kill the handler thread after N seconds of inactivity (the default is 20 seconds):
    a :: Snap () a = setTimeout 30 
  8. Throw and catch exceptions using a MonadBaseControl instance:
    import Control.Exception.Lifted
    (SomeException, throwIO, catch) foo :: Snap ()
    foo = bar `catch` (e::SomeException) -> baz where bar =
    throwIO FooException 
  9. Log a message to the error log:
    foo :: Snap () foo =
    logError "grumble." 
You may notice that most of the type signatures in this module contain a (MonadSnap m) => ... typeclass constraint. MonadSnap is a typeclass which, in essence, says "you can get back to the Snap monad from here". Using MonadSnap you can extend the Snap monad with additional functionality and still have access to most of the Snap functions without writing lift everywhere. Instances are already provided for most of the common monad transformers (ReaderT, WriterT, StateT, etc.).
This module provides convenience exports of the modules most commonly used when developing with the Snap Framework. For documentation about Snaplets, see Snap.Snaplet. For the core web server API, see Snap.Core.
Snap integration for the WebSockets library
Modifies a PackageDescription by appending a snapshot number corresponding to the given date.
Modifies a Version by appending a snapshot number corresponding to the given date.
Snap: A Haskell Web Framework (core interfaces and types) Snap is a simple and fast web development framework and server written in Haskell. For more information or to download the latest version, you can visit the Snap project website at http://snapframework.com/. This library contains the core definitions and types for the Snap framework, including:
  1. Primitive types and functions for HTTP (requests, responses, cookies, post/query parameters, etc)
  2. A monad for programming web handlers called "Snap", which allows:
  • Stateful access to the HTTP request and response objects
  • Monadic failure (i.e. MonadPlus/Alternative instances) for declining to handle requests and chaining handlers together
  • Early termination of the computation if you know early what you want to return and want to prevent further monadic processing
Quick start: The Snap monad and HTTP definitions are in Snap.Core.
Constructs a url relative to the current snaplet.
A web server for the Snap Framework Snap is a simple and fast web development framework and server written in Haskell. For more information or to download the latest version, you can visit the Snap project website at http://snapframework.com/. The Snap HTTP server is a high performance web server library written in Haskell. Together with the snap-core library upon which it depends, it provides a clean and efficient Haskell programming interface to the HTTP protocol.
A short string describing the Snap server version
Appends a stroked border rectangle inside the given outline. The four sides of the border can have different widths and colors.
Creates a new CairoNode and appends it to the current render node of snapshot, without changing the current node.
Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot. You should try to avoid calling this function if color is transparent.
Appends a conic gradient node with the given stops to snapshot.
A convenience method to fill a path with a color. See snapshotPushFill if you need to fill a path with more complex content than a color. Since: 4.14
Appends an inset shadow into the box given by outline.
Creates render nodes for rendering layout in the given foregound color and appends them to the current node of snapshot without changing the current node. The current theme's foreground color for a widget can be obtained with widgetGetColor. Note that if the layout does not produce any visible output, then nodes may not be added to the snapshot.
Appends a linear gradient node with the given stops to snapshot.
Appends node to the current render node of snapshot, without changing the current node. If snapshot does not have a current node yet, node will become the initial node.
Appends an outset shadow node around the box given by outline.