forked from bortzmeyer/GaBuZoMeu
61 lines
2.8 KiB
Haskell
61 lines
2.8 KiB
Haskell
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,
|
|
lang'scope::Maybe String,
|
|
lang'comment::Maybe String
|
|
}
|
|
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],
|
|
script'added::DateTime, script'comment::Maybe String} deriving Show
|
|
|
|
data Region = Region {region'subtag::String, region'descr::[String],
|
|
region'added::DateTime, region'comment::Maybe String} deriving Show
|
|
-- TODO: Deprecated and preferredValue
|
|
|
|
data Variant = Variant {variant'subtag::String, variant'descr::[String],
|
|
variant'added::DateTime, variant'prefix::[String],
|
|
variant'comment::Maybe String} deriving Show
|
|
|
|
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)
|