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

Web.Hyperbole.Effect.Respond

Synopsis

Documentation

respondEarly :: forall (es :: [Effect]) id. (Hyperbole :> es, HyperView id es) => id -> View id () -> Eff es () Source #

Respond with the given view, and stop execution

notFound :: forall (es :: [Effect]) a. Hyperbole :> es => Eff es a Source #

Respond immediately with 404 Not Found

userLoad :: (Hyperbole :> es, Users :> es) => UserId -> Eff es User
userLoad uid = do
  mu <- send (LoadUser uid)
  maybe notFound pure mu

myPage :: (Hyperbole :> es, Users :> es) => Eff es View
myPage = do
  load $ do
    u <- userLoad 100
    -- skipped if user = Nothing
    pure $ userView u

parseError :: forall (es :: [Effect]) a. Hyperbole :> es => Text -> Eff es a Source #

Respond immediately with a parse error

redirect :: forall (es :: [Effect]) a. Hyperbole :> es => Url -> Eff es a Source #

Redirect immediately to the Url

view :: forall (es :: [Effect]). Hyperbole :> es => View () () -> Eff es Response Source #

Manually set the response to the given view. Normally you return a View from load or handle instead of using this