Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class YamlSchema a where
- yamlSchema :: YamlParser a
- yamlSchemaList :: YamlParser [a]
- class YamlKeySchema a where
- yamlKeySchema :: KeyParser a
- boundedIntegerSchema :: (Integral i, Bounded i) => YamlParser i
- requiredField :: YamlSchema a => Text -> Text -> ObjectParser a
- requiredField' :: YamlSchema a => Text -> ObjectParser a
- optionalField :: YamlSchema a => Text -> Text -> ObjectParser (Maybe a)
- optionalField' :: YamlSchema a => Text -> ObjectParser (Maybe a)
- optionalFieldWithDefault :: (Show a, YamlSchema a) => Text -> a -> Text -> ObjectParser a
- optionalFieldWithDefault' :: (Show a, YamlSchema a) => Text -> a -> ObjectParser a
- viaYamlSchema :: YamlSchema a => Value -> Parser a
- newtype ViaYamlSchema a = ViaYamlSchema a
Documentation
class YamlSchema a where Source #
A class of types for which a schema is defined.
Note that you do not have to use this class and can just use your own parser values. Note also that the parsing of a type of this class should correspond to the parsing of the type in the FromJSON class.
yamlSchema :: YamlParser a Source #
A yamlschema for one value
See the sections on helper functions for implementing this for plenty of examples.
yamlSchemaList :: YamlParser [a] Source #
Instances
class YamlKeySchema a where Source #
A class of types for which a schema for keys is defined.
yamlKeySchema :: KeyParser a Source #
Instances
YamlKeySchema String Source # | |
Defined in YamlParse.Applicative.Class | |
YamlKeySchema Text Source # | |
Defined in YamlParse.Applicative.Class |
boundedIntegerSchema :: (Integral i, Bounded i) => YamlParser i Source #
requiredField :: YamlSchema a => Text -> Text -> ObjectParser a Source #
A parser for a required field in an object at a given key
requiredField' :: YamlSchema a => Text -> ObjectParser a Source #
A parser for a required field in an object at a given key without a help text
optionalField :: YamlSchema a => Text -> Text -> ObjectParser (Maybe a) Source #
A parser for an optional field in an object at a given key
optionalField' :: YamlSchema a => Text -> ObjectParser (Maybe a) Source #
A parser for an optional field in an object at a given key without a help text
optionalFieldWithDefault :: (Show a, YamlSchema a) => Text -> a -> Text -> ObjectParser a Source #
A parser for an optional field in an object at a given key with a default value
optionalFieldWithDefault' :: (Show a, YamlSchema a) => Text -> a -> ObjectParser a Source #
A parser for an optional field in an object at a given key with a default value without a help text
viaYamlSchema :: YamlSchema a => Value -> Parser a Source #
Helper function to implement FromJSON
via YamlSchema
Example:
instance FromJSON Config where parseJSON = viaYamlSchema
newtype ViaYamlSchema a Source #
A helper newtype to parse a yaml value using the YamlSchema parser.
Example:
case Data.Yaml.decodeEither' contents of Left e -> die $ show e Right (ViaYamlSchema res) -> print res
This only helps you when you really don't want to implement a FromJSON
instance.
See viaYamlSchema
if you do.