Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class IsRoute r => EmaSite r where
- type SiteArg r :: Type
- type SiteOutput r :: Type
- siteInput :: forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> SiteArg r -> m (Dynamic m (RouteModel r))
- siteOutput :: forall m. (MonadIO m, MonadLoggerIO m) => Prism' FilePath r -> RouteModel r -> r -> m (SiteOutput r)
- type EmaStaticSite r = (EmaSite r, SiteOutput r ~ Asset LByteString)
Documentation
class IsRoute r => EmaSite r where Source #
Typeclass to orchestrate an Ema site
Given a route r
from the class of IsRoute
types, instantiating EmaSite
on it enables defining the site build pipeline as follows:
SiteArg -> siteInput -> Dynamic model --[r, model]--> siteOutput
SiteArg
is typically not used, but it can be used to pass command line arguments and other such settings.siteInput
returns a time-varying value (Dynamic) representing the data for your static site.siteOutput
takes this data model (oneshot value) and returns the generated content (usually HTML asset, perSiteOutput
) for the given route.
Finally, `Ema.App.runSite @r arg` (where arg
is of type SiteArg
) is run
from the main
entry point to run your Ema site.
type SiteArg r :: Type Source #
SiteArg
is typically settings from the environment (config file, or
command-line arguments) that your Dynamic-producing siteInput
function
consumes as argument.
type SiteArg r = ()
type SiteOutput r :: Type Source #
Type of the value returned by siteOutput
. Usually `Asset LByteString`
but it can be anything.
type SiteOutput r = Asset LByteString
:: forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) | |
=> Some Action | |
-> SiteArg r | The value passed by the programmer to |
-> m (Dynamic m (RouteModel r)) | Time-varying value of the model. If your model is not time-varying, use
|
Get the model's time-varying value as a Dynamic
.
If your model is not time-varying, use pure
to produce a constant value.
siteOutput :: forall m. (MonadIO m, MonadLoggerIO m) => Prism' FilePath r -> RouteModel r -> r -> m (SiteOutput r) Source #
Return the output (typically an Asset
) for the given route and model.
Instances
type EmaStaticSite r = (EmaSite r, SiteOutput r ~ Asset LByteString) Source #
Like EmaSite
but SiteOutput
is a bytestring Asset
.