purview-0.2.0.2: A simple, fun way to build websites
Safe HaskellSafe-Inferred
LanguageHaskell2010

Purview.Server

Synopsis

Documentation

serve :: Monad m => Configuration m -> (String -> Purview () m) -> IO () Source #

This starts up the Warp server.

Example:

import Purview.Server

view url = p [ text "hello world" ]

main = serve defaultConfiguration view

data Configuration m Source #

Constructors

Configuration 

Fields

  • interpreter :: m [Event] -> IO [Event]

    How to run your algebraic effects or other. This will apply to all effectHandlers.

  • logger :: String -> IO ()

    Specify what to do with logs

  • eventsToListenTo :: [String]

    For extending the handled events. By default it covers the usual click, change, focus(in/out)

  • htmlHead :: String

    This is placed directly into the <head>, so that you can link to external CSS etc

  • devMode :: Bool

    When enabled, Purview will send the whole tree on websocket reconnection. This enables you to use "ghcid --command 'stack ghci examples/Main.hs' --test :main`" to restart the server on file change, and get a kind of live reloading

  • javascript :: String
     
  • port :: Int

    the port to run on

  • secure :: Bool

    whether the websocket tries to connect using ws:/ or wss:/ locally you probably want this false, in prod secure of course

startWebSocketLoop :: (Monad m, Typeable action) => Configuration m -> Purview action m -> Connection -> IO () Source #