Definition of a YAML 1.2 Schema
A YAML schema defines how implicit tags are resolved to concrete tags and how data is represented textually in YAML.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
ModuleHsYAML-0.2.1.4Haskell2010
Predefined YAML 1.2 Schema resolvers and encoders as well as support for defining custom resolvers and encoders.
Definition of a YAML 1.2 Schema
A YAML schema defines how implicit tags are resolved to concrete tags and how data is represented textually in YAML.
"Failsafe" schema resolver as specified in YAML 1.2 / 10.1.2. Tag Resolution
Strict JSON schema resolver as specified in YAML 1.2 / 10.2.2. Tag Resolution
Core schema resolver as specified in YAML 1.2 / 10.3.2. Tag Resolution
"Failsafe" schema encoder as specified in YAML 1.2 / 10.1.2. Tag Resolution
Strict JSON schema encoder as specified in YAML 1.2 / 10.2.2. Tag Resolution
Core schema encoder as specified in YAML 1.2 / 10.3.2. Tag Resolution
According to YAML 1.2 the recommended default SchemaEncoder is coreSchemaEncoder under which Scalars are encoded as follows:
String which are made of Plain Characters (see isPlainChar), unambiguous (see isAmbiguous) and do not contain any leading/trailing spaces are encoded as Plain Scalar.
Rest of the strings are encoded in DoubleQuotes
Booleans are encoded using encodeBool
Double values are encoded using encodeDouble
Integral values are encoded using encodeInt
Set the Scalar style in the encoded YAML. This is a function that decides for each Scalar the type of YAML string to output.
WARNING: You must ensure that special strings (like "true"/"false"/"null"/"1234") are not encoded with the Plain style, because
then they will be decoded as boolean, null or numeric values. You can use isAmbiguous to detect them.
NOTE: For different SchemaResolvers, different strings are ambiguous. For example, "true" is not ambiguous for failsafeSchemaResolver.
These are some characters which can be used in Plain Scalars safely without any quotes (see Indicator Characters).
NOTE: This does not mean that other characters (like "\n" and other special characters like "-?:,[]{}#&*!,>%@`"'") cannot be used in Plain Scalars.
Returns True if the string can be decoded by the given SchemaResolver into a Scalar which is not a of type SStr.
isAmbiguous coreSchemaResolver "true"True
isAmbiguous failSchemaResolver "true"False
Encode Double
Encode Boolean
Encode Integer