module Hydra.Impl.Haskell.Sources.Ext.Xml.Schema where

import Hydra.Impl.Haskell.Sources.Core

import Hydra.All
import Hydra.Impl.Haskell.Dsl.Types as Types
import Hydra.Impl.Haskell.Dsl.Standard


xmlSchemaModule :: Module Meta
xmlSchemaModule :: Module Meta
xmlSchemaModule = forall m.
Namespace -> [Element m] -> [Module m] -> Maybe String -> Module m
Module Namespace
ns [Element Meta]
elements [] forall a b. (a -> b) -> a -> b
$
    forall a. a -> Maybe a
Just (String
"A partial XML Schema model, focusing on datatypes. All simple datatypes (i.e. xsd:anySimpleType and below) are included.\n" forall a. [a] -> [a] -> [a]
++
      String
"See: https://www.w3.org/TR/xmlschema-2\n" forall a. [a] -> [a] -> [a]
++
      String
"Note: for most of the XML Schema datatype definitions included here, the associated Hydra type is simply\n" forall a. [a] -> [a] -> [a]
++
      String
"      the string type. Exceptions are made for xsd:boolean and most of the numeric types, where there is a clearly\n" forall a. [a] -> [a] -> [a]
++
      String
"      corresponding Hydra literal type.")
  where
    ns :: Namespace
ns = String -> Namespace
Namespace String
"hydra/ext/xml/schema"
    def :: String -> Type m -> Element m
def = forall m. Namespace -> String -> Type m -> Element m
datatype Namespace
ns

    elements :: [Element Meta]
elements = forall {m}. [Element m]
datatypes forall a. [a] -> [a] -> [a]
++ [Element Meta]
others

    datatypes :: [Element m]
datatypes = [
      forall {m}. String -> Type m -> Element m
def String
"AnySimpleType" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"AnyType" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"AnyURI" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Base64Binary" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Boolean" forall m. Type m
boolean,
      forall {m}. String -> Type m -> Element m
def String
"Byte" forall m. Type m
int8,
      forall {m}. String -> Type m -> Element m
def String
"Date" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"DateTime" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Decimal" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Double" forall m. Type m
float64,
      forall {m}. String -> Type m -> Element m
def String
"Duration" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"ENTITIES" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"ENTITY" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Float" forall m. Type m
float32,
      forall {m}. String -> Type m -> Element m
def String
"GDay" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"GMonth" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"GMonthDay" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"GYear" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"GYearMonth" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"HexBinary" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"ID" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"IDREF" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"IDREFS" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Int" forall m. Type m
int32,
      forall {m}. String -> Type m -> Element m
def String
"Integer" forall m. Type m
bigint,
      forall {m}. String -> Type m -> Element m
def String
"Language" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Long" forall m. Type m
int64,
      forall {m}. String -> Type m -> Element m
def String
"NMTOKEN" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"NOTATION" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Name" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"NegativeInteger" forall m. Type m
bigint,
      forall {m}. String -> Type m -> Element m
def String
"NonNegativeInteger" forall m. Type m
bigint,
      forall {m}. String -> Type m -> Element m
def String
"NonPositiveInteger" forall m. Type m
bigint,
      forall {m}. String -> Type m -> Element m
def String
"NormalizedString" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"PositiveInteger" forall m. Type m
bigint,
      forall {m}. String -> Type m -> Element m
def String
"QName" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Short" forall m. Type m
int16,
      forall {m}. String -> Type m -> Element m
def String
"String" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Time" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"Token" forall m. Type m
string,
      forall {m}. String -> Type m -> Element m
def String
"UnsignedByte" forall m. Type m
uint8,
      forall {m}. String -> Type m -> Element m
def String
"UnsignedInt" forall m. Type m
uint32,
      forall {m}. String -> Type m -> Element m
def String
"UnsignedLong" forall m. Type m
uint64,
      forall {m}. String -> Type m -> Element m
def String
"UnsignedShort" forall m. Type m
uint16]

    others :: [Element Meta]
others = [
      forall {m}. String -> Type m -> Element m
def String
"ConstrainingFacet" forall a b. (a -> b) -> a -> b
$
        String -> Type Meta -> Type Meta
see String
"https://www.w3.org/TR/xmlschema-2/#non-fundamental" forall a b. (a -> b) -> a -> b
$
        forall m. Type m
unit, -- TODO: concrete facets

      forall {m}. String -> Type m -> Element m
def String
"Datatype" forall a b. (a -> b) -> a -> b
$ forall m. [String] -> Type m
enum [
        String
"anySimpleType",
        String
"anyType",
        String
"anyURI",
        String
"base64Binary",
        String
"boolean",
        String
"byte",
        String
"date",
        String
"dateTime",
        String
"decimal",
        String
"double",
        String
"duration",
        String
"ENTITIES",
        String
"ENTITY",
        String
"float",
        String
"gDay",
        String
"gMonth",
        String
"gMonthDay",
        String
"gYear",
        String
"gYearMonth",
        String
"hexBinary",
        String
"ID",
        String
"IDREF",
        String
"IDREFS",
        String
"int",
        String
"integer",
        String
"language",
        String
"long",
        String
"NMTOKEN",
        String
"NOTATION",
        String
"name",
        String
"negativeInteger",
        String
"nonNegativeInteger",
        String
"nonPositiveInteger",
        String
"normalizedString",
        String
"positiveInteger",
        String
"qName",
        String
"short",
        String
"string",
        String
"time",
        String
"token",
        String
"unsignedByte",
        String
"unsignedInt",
        String
"unsignedLong",
        String
"unsignedShort"]]