Working generation, need to add list functions

This commit is contained in:
Macocian Adrian Radu
2022-05-19 01:53:19 +02:00
parent 26daa85feb
commit e73ff31f1d
18 changed files with 2521 additions and 88 deletions

View File

@@ -1,4 +1,5 @@
module Model.Enum where
import Model.Type
-- |The representation of a Rosetta enum data type
data EnumType = MakeEnum {
@@ -12,4 +13,11 @@ data EnumValue = MakeEnumValue {
enumValueName :: String,
enumValueDescription :: Maybe String,
enumValueDisplayName :: Maybe String
} deriving (Show, Eq)
} deriving (Show, Eq)
convertEnumToType :: EnumType -> Type
convertEnumToType (MakeEnum name desc val) = MakeType name (BasicType "Object") desc (map (convertValueToAttribute typ) val) [MakeCondition Nothing (Keyword "one-of")]
where typ = MakeType name (BasicType "Object") desc [] [MakeCondition Nothing (Keyword "one-of")]
convertValueToAttribute :: Type -> EnumValue -> TypeAttribute
convertValueToAttribute typ (MakeEnumValue name desc _) = MakeTypeAttribute name typ (Bounds (0, 1)) Nothing