module Hydra.Sources.Tier4.Langs.Yaml.Model where

import Hydra.Sources.Tier3.All
import Hydra.Dsl.Annotations
import Hydra.Dsl.Bootstrap
import Hydra.Dsl.Types as Types


yamlModelModule :: Module
yamlModelModule :: Module
yamlModelModule = Namespace
-> [Element] -> [Module] -> [Module] -> Maybe String -> Module
Module Namespace
ns [Element]
elements [Module
hydraCoreModule] [Module]
tier0Modules (Maybe String -> Module) -> Maybe String -> Module
forall a b. (a -> b) -> a -> b
$
    String -> Maybe String
forall a. a -> Maybe a
Just (String
"A basic YAML representation model. Based on:\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
      String
"  https://yaml.org/spec/1.2/spec.html\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
      String
"The Serialization and Presentation properties of YAML,\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
      String
"including directives, comments, anchors, style, formatting, and aliases, are not supported by this model.\n" String -> String -> String
forall a. [a] -> [a] -> [a]
++
      String
"In addition, tags are omitted from this model, and non-standard scalars are unsupported.")
  where
    ns :: Namespace
ns = String -> Namespace
Namespace String
"hydra/langs/yaml/model"
    def :: String -> Type -> Element
def = Namespace -> String -> Type -> Element
datatype Namespace
ns
    model :: String -> Type
model = Namespace -> String -> Type
typeref Namespace
ns

    elements :: [Element]
elements = [
      {-
      Every YAML node has an optional scalar tag or non-specific tag (omitted from this model)
      -}
      String -> Type -> Element
def String
"Node" (Type -> Element) -> Type -> Element
forall a b. (a -> b) -> a -> b
$
        String -> Type -> Type
doc String
"A YAML node (value)" (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$
        [FieldType] -> Type
union [
          String
"mapping"String -> Type -> FieldType
>: Type -> Type -> Type
Types.map (String -> Type
model String
"Node") (String -> Type
model String
"Node"), -- Failsafe schema: tag:yaml.org,2002:map
          String
"scalar"String -> Type -> FieldType
>: String -> Type
model String
"Scalar",
          String
"sequence"String -> Type -> FieldType
>: Type -> Type
list (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ String -> Type
model String
"Node"], -- Failsafe schema: tag:yaml.org,2002:seq

      String -> Type -> Element
def String
"Scalar" (Type -> Element) -> Type -> Element
forall a b. (a -> b) -> a -> b
$
        String -> Type -> Type
doc String
"A union of scalars supported in the YAML failsafe and JSON schemas. Other scalars are not supported here" (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$
        [FieldType] -> Type
union [
          {-
          Represents a true/false value

          JSON schema: tag:yaml.org,2002:bool
          -}
          String
"bool"String -> Type -> FieldType
>:
            String -> Type -> Type
doc String
"Represents a true/false value"
            Type
boolean,
          {-
          Represents an approximation to real numbers

          JSON schema: tag:yaml.org,2002:float

          In addition to arbitrary-precision floating-point numbers in scientific notation,
          YAML allows for three special values, which are not supported here:
          positive and negative infinity (.inf and -.inf), and "not a number (.nan)
          -}
          String
"float"String -> Type -> FieldType
>:
            String -> Type -> Type
doc String
"Represents an approximation to real numbers"
            Type
bigfloat,
          {-
          Represents arbitrary sized finite mathematical integers

          JSON schema: tag:yaml.org,2002:int
          -}
          String
"int"String -> Type -> FieldType
>:
            String -> Type -> Type
doc String
"Represents arbitrary sized finite mathematical integers"
            Type
bigint,
          {-
          Represents the lack of a value

          JSON schema: tag:yaml.org,2002:null
          -}
          String
"null"String -> Type -> FieldType
>:
            String -> Type -> Type
doc String
"Represents the lack of a value"
            Type
unit,
          {-
          Failsafe schema: tag:yaml.org,2002:str
          -}
          String
"str"String -> Type -> FieldType
>:
            String -> Type -> Type
doc String
"A string value"
            Type
string]]