Safe Haskell | None |
---|---|
Language | Haskell2010 |
The package provides the configuration loader.
An configuration example:
_vars: window: width: 800 height: 600 app: - name: message-layer properties: window: image: resources/window-base.png position: x: 0 y: ${${var:window.height} - ${ref:..size.height}} size: width: ${var:window.width} height: 150
Syntax
_vars
You can define a new variable. Use object syntax under the _vars
field.
The variables can be referenced in all siblings and under their siblings to the _vars
, in the variable syntax ${var:_path_}
.
Expr
In each field, you can specify an expression defined in the loader.
${}
: enclose the expr by${}
, to tell the parsers that the field is an expr not a plain string.${ref:_path_}
: specify any path to refer any other value. The path resolution is performed once, not recursively resolved._path_
consists of field names splitted by a period. Use double dots..
for a parent.${var:_path_}
: specify any path to value defined at the field._path_
consists of field names splitted by a period.- arithmetic operator: addition, subtraction, multiplication and division (
+,-,*,/
) can also be used in${}
.
Synopsis
- module MiniLight.Loader.Internal.Types
- createComponentBy :: (HasLoaderEnv env, HasLightEnv env, MonadIO m) => Resolver -> Maybe Text -> ComponentConfig -> LightT env m (Either String Component)
- lookupByTagID :: (HasLightEnv env, HasLoaderEnv env, MonadIO m) => Text -> LightT env m (Maybe Text)
- data LoaderEnv = LoaderEnv {}
- class HasLoaderEnv c where
- resolveConfig :: MonadIO m => FilePath -> m (Either Text AppConfig)
- loadAppConfig :: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) => FilePath -> Resolver -> LightT env m ()
- patchAppConfig :: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) => FilePath -> Resolver -> LightT env m ()
- resolve :: Value -> Value
- parseAppConfig :: Value -> Either Text AppConfig
Documentation
createComponentBy :: (HasLoaderEnv env, HasLightEnv env, MonadIO m) => Resolver -> Maybe Text -> ComponentConfig -> LightT env m (Either String Component) Source #
Create a component with given resolver.
lookupByTagID :: (HasLightEnv env, HasLoaderEnv env, MonadIO m) => Text -> LightT env m (Maybe Text) Source #
The environment for config loader
class HasLoaderEnv c where Source #
loaderEnv :: Lens' c LoaderEnv Source #
_appConfig :: Lens' c (IORef AppConfig) Source #
_registry :: Lens' c (Registry Component) Source #
_tagRegistry :: Lens' c (IORef (HashMap Text Text)) Source #
Instances
resolveConfig :: MonadIO m => FilePath -> m (Either Text AppConfig) Source #
Load an config file and return the resolved AppConfig
.
:: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) | |
=> FilePath | Filepath to the yaml file. |
-> Resolver | Specify any resolver. |
-> LightT env m () |
Load an config file and set in the environment. Calling this function at once, this overrides all values in the environment.
This will generate an error log and skip the component if the configuration is invalid.
This function also assign unique IDs for each component, using assignUID
.
:: (HasLightEnv env, HasLoaderEnv env, MonadIO m, MonadCatch m) | |
=> FilePath | Filepath to the yaml file. |
-> Resolver | Specify any resolver. |
-> LightT env m () |
Load the config file again and place the newly loaded components. This is used for HCR (hot component replacement).
Call loadAppConfig
first.