hyperbole-0.4.2: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellNone
LanguageGHC2021

Web.Hyperbole.Page

Synopsis

Documentation

type Page (views :: [Type]) = View (Root views) () Source #

Conceptually, an application is dividied up into multiple Pages. Each page module should have a function that returns a Page. The Page itself is a View with a type-level list of HyperViews used on the page.

page :: Eff es (Page [Message, Count])
page = do
  pure $ do
    row id $ do
      hyper Message $ messageView "Hello"
      hyper Count $ countView 0

runPage :: forall (es :: [Effect]) (views :: [Type]). (Hyperbole :> es, RunHandlers views es) => Eff es (Page views) -> Eff es Response Source #

Run a Page and return a Response

main :: IO ()
main = do
  run 3000 $ do
    liveApp (basicDocument "Example") (runPage page)

page :: Eff es (Page '[])
page = do
  pure $ do
    col (pad 10) $ do
      el bold "Hello World"