Safe Haskell | None |
---|
Config
Description
Contains metadata for the application as well as values needed for SKAT to run.
Synopsis
- data Dotfile = Dotfile {
- templates' :: Last RelDir
- output' :: Last (Map String RelDir)
- filenameSeparator' :: Last (Maybe Char)
- data ConfigError
- = CouldNotMakeConfig String
- | InvalidOutputMap String
- | DuplicateOutputMapError String
- | InvalidOutputPath String
- handleConfigResult :: Maybe GenConfig -> Either ConfigError GenConfig
- mkDirPath :: (String -> Dir os) -> Text -> Last (Dir os)
- mkOutputDirs :: Map String String -> Last (Map String RelDir)
- data GenConfig = GenConfig {
- templatesDir :: RelDir
- outputDirs :: Map String RelDir
- separator :: Maybe Char
- dotfileName :: String
- makeDefaultConfig :: Dotfile
- emptyConfigOption :: Dotfile
- decodeConfig :: String -> Dotfile
- mkDotfile :: Last RelDir -> Last (Map String RelDir) -> Last (Maybe Char) -> Dotfile
- mkConfig :: Dotfile -> String -> Maybe GenConfig
- data InitDotfile = InitDotfile {
- templatesVal :: RelDir
- outputVal :: Map String RelDir
- filenameSeparatorVal :: Maybe Char
- data InitDotfileSerializable = InitDotfileSerializable {
- templates :: String
- output :: Map String String
- filenameSeparator :: String
- initDotFileToSerializable :: InitDotfile -> InitDotfileSerializable
- mkInitDotfile :: RelDir -> Map String RelDir -> Maybe Char -> InitDotfile
- parseTemplatesPath :: String -> Maybe RelDir
- mkInvalidOutputMapError :: [String] -> ConfigError
- mkDuplicateOutputMapError :: (String, String) -> Map String String -> ConfigError
- parseOutputMap :: String -> Maybe (Map String RelDir)
- parseSeparator :: String -> Maybe (Maybe Char)
Documentation
It represents the data coming from the configuration file. More data can be needed but may not be configurable. The Dotfile is used to create a GenConfig which will be used by the application.
Constructors
Dotfile | |
Fields
|
Instances
Show Dotfile # | |
Generic Dotfile # | |
Semigroup Dotfile # | |
FromJSON Dotfile # | |
Defined in Config | |
type Rep Dotfile # | |
Defined in Config type Rep Dotfile = D1 ('MetaData "Dotfile" "Config" "main" 'False) (C1 ('MetaCons "Dotfile" 'PrefixI 'True) (S1 ('MetaSel ('Just "templates'") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last RelDir)) :*: (S1 ('MetaSel ('Just "output'") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last (Map String RelDir))) :*: S1 ('MetaSel ('Just "filenameSeparator'") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Last (Maybe Char)))))) |
data ConfigError #
Encompasses all possible errors in the Config module
Constructors
CouldNotMakeConfig String | Cannot create a valid config from all inputs |
InvalidOutputMap String | Output map has invalid values |
DuplicateOutputMapError String | Output map has duplicated values |
InvalidOutputPath String | Output value is not a valid RelPath |
Instances
Show ConfigError # | |
Defined in Config Methods showsPrec :: Int -> ConfigError -> ShowS show :: ConfigError -> String showList :: [ConfigError] -> ShowS |
handleConfigResult :: Maybe GenConfig -> Either ConfigError GenConfig #
Transform maybe config to an Either of the correct Domain error or the valid Config
mkOutputDirs :: Map String String -> Last (Map String RelDir) #
This is the configuration used by the application wtih all the metadata needed to generate code.
Constructors
GenConfig | |
Fields
|
dotfileName :: String #
Name for the dotfile where the configuration will be read from
decodeConfig :: String -> Dotfile #
Arguments
:: Last RelDir | Templates directory path relative to the root. |
-> Last (Map String RelDir) | Configuration for the output. Keys are matched on the names of the templates, the values are relative directory paths inside the root. |
-> Last (Maybe Char) | Character used to separate the template filename and make use of suffix. |
-> Dotfile |
Factory function for constructing a Dotfile
mkConfig :: Dotfile -> String -> Maybe GenConfig #
Factory to make a GenConfig from a JSONString. It will attempt to construct a Dotfile from its values and then combine it with a default config. The result will be the GenConfig that will be returned.
>>>
mkConfig "{ \"root\": \"/dummy/project\", \"templates\": \".skat/templates\", \"filenameSeparator\": \".\", \"output\": { \"component\": \"./components\" }}"
data InitDotfile #
Constructors
InitDotfile | |
Fields
|
Instances
Show InitDotfile # | |
Defined in Config Methods showsPrec :: Int -> InitDotfile -> ShowS show :: InitDotfile -> String showList :: [InitDotfile] -> ShowS |
data InitDotfileSerializable #
Constructors
InitDotfileSerializable | |
Fields
|
Instances
Show InitDotfileSerializable # | |
Defined in Config Methods showsPrec :: Int -> InitDotfileSerializable -> ShowS show :: InitDotfileSerializable -> String showList :: [InitDotfileSerializable] -> ShowS | |
Generic InitDotfileSerializable # | |
Defined in Config Associated Types type Rep InitDotfileSerializable :: Type -> Type Methods from :: InitDotfileSerializable -> Rep InitDotfileSerializable x to :: Rep InitDotfileSerializable x -> InitDotfileSerializable | |
ToJSON InitDotfileSerializable # | |
Defined in Config Methods toJSON :: InitDotfileSerializable -> Value toEncoding :: InitDotfileSerializable -> Encoding toJSONList :: [InitDotfileSerializable] -> Value toEncodingList :: [InitDotfileSerializable] -> Encoding | |
type Rep InitDotfileSerializable # | |
Defined in Config type Rep InitDotfileSerializable = D1 ('MetaData "InitDotfileSerializable" "Config" "main" 'False) (C1 ('MetaCons "InitDotfileSerializable" 'PrefixI 'True) (S1 ('MetaSel ('Just "templates") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "output") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map String String)) :*: S1 ('MetaSel ('Just "filenameSeparator") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))) |
mkInitDotfile :: RelDir -> Map String RelDir -> Maybe Char -> InitDotfile #
parseTemplatesPath :: String -> Maybe RelDir #
mkInvalidOutputMapError :: [String] -> ConfigError #
mkDuplicateOutputMapError :: (String, String) -> Map String String -> ConfigError #
parseOutputMap :: String -> Maybe (Map String RelDir) #
parseSeparator :: String -> Maybe (Maybe Char) #