2023-06-08 21:49:35 +02:00
|
|
|
module Registry.Types where
|
|
|
|
|
|
|
|
-- TODO: import Time and use CalendarTime
|
|
|
|
type DateTime = String
|
|
|
|
|
|
|
|
data Language = Language {lang'subtag::String, lang'descr::[String],
|
|
|
|
lang'added::DateTime, lang'script::Maybe String,
|
|
|
|
lang'preferredValue::Maybe String,
|
|
|
|
lang'macroLanguage::Maybe String,
|
|
|
|
lang'deprecated::Maybe DateTime,
|
2023-09-06 18:25:16 +02:00
|
|
|
lang'scope::Maybe String,
|
|
|
|
lang'comment::Maybe String
|
|
|
|
}
|
2023-06-08 21:49:35 +02:00
|
|
|
deriving Show
|
|
|
|
|
|
|
|
data Extlang = Extlang {extlang'subtag::String, extlang'descr::[String],
|
|
|
|
extlang'added::DateTime, extlang'script::Maybe String,
|
|
|
|
extlang'prefix::String, -- An extlang can have only one prefix
|
|
|
|
extlang'preferredValue::Maybe String,
|
|
|
|
extlang'macroLanguage::Maybe String,
|
|
|
|
extlang'scope::Maybe String}
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
data Script = Script {script'subtag::String, script'descr::[String],
|
2023-09-30 17:31:16 +02:00
|
|
|
script'added::DateTime, script'deprecated::Maybe DateTime, script'comment::Maybe String} deriving Show
|
2023-06-08 21:49:35 +02:00
|
|
|
|
|
|
|
data Region = Region {region'subtag::String, region'descr::[String],
|
2023-09-30 17:31:16 +02:00
|
|
|
region'added::DateTime, region'deprecated::Maybe DateTime, region'comment::Maybe String} deriving Show
|
|
|
|
-- TODO: PreferredValue
|
2023-06-08 21:49:35 +02:00
|
|
|
|
|
|
|
data Variant = Variant {variant'subtag::String, variant'descr::[String],
|
2023-09-06 18:25:16 +02:00
|
|
|
variant'added::DateTime, variant'prefix::[String],
|
2023-09-30 17:31:16 +02:00
|
|
|
variant'deprecated::Maybe DateTime,
|
2023-09-06 18:25:16 +02:00
|
|
|
variant'comment::Maybe String} deriving Show
|
2023-06-08 21:49:35 +02:00
|
|
|
|
|
|
|
data Redundant = Redundant {redundant'tag::String, redundant'descr::[String],
|
|
|
|
redundant'added::DateTime} deriving Show
|
|
|
|
|
|
|
|
data Grandfathered = Grandfathered {gf'tag::String, gf'descr::[String],
|
|
|
|
gf'added::DateTime} deriving Show
|
|
|
|
|
|
|
|
-- TODO: implements them
|
|
|
|
data Extension = Extension {ext'added::DateTime} deriving Show
|
|
|
|
|
|
|
|
data Record = Reg Region | Lang Language | Extl Extlang | Scr Script | Var Variant |
|
|
|
|
Red Redundant | GF Grandfathered | Ext Extension | Date DateTime deriving Show
|
|
|
|
|
|
|
|
type Registry = [Record]
|
|
|
|
|
|
|
|
data CheckResult = Success Registry | SyntaxError String | SemanticError String
|
|
|
|
deriving Show
|
|
|
|
|
|
|
|
combineC (Success r1) (Success r2) = Success r1
|
|
|
|
combineC (Success r) (SyntaxError e) = SyntaxError e
|
|
|
|
combineC (SyntaxError e) (Success r) = SyntaxError e
|
|
|
|
combineC (Success r) (SemanticError e) = SemanticError e
|
|
|
|
combineC (SemanticError e) (Success r) = SemanticError e
|
|
|
|
combineC (SyntaxError e1) (SemanticError e2) = SyntaxError e1
|
|
|
|
combineC (SemanticError e2) (SyntaxError e1) = SyntaxError e1
|
|
|
|
combineC (SyntaxError e1) (SyntaxError e2) = SyntaxError (e1 ++ " ; " ++ e2)
|
|
|
|
combineC (SemanticError e1) (SemanticError e2) = SemanticError (e1 ++ " ; " ++ e2)
|