Safe Haskell | None |
---|---|
Language | Haskell2010 |
Defines an api spec (to be built after the static checking of the AST) and helper methods over it.
- type Id = String
- type Route = String
- type EnumValue = String
- type EnumInfo = [EnumValue]
- data Modifier
- newtype FieldInfo = FI (Id, Type, Set Modifier)
- type StructInfo = [FieldInfo]
- type ResourceInfo = (Route, Writable)
- data Type
- type Enums = Map Id EnumInfo
- type Structs = [(Id, StructInfo)]
- type Resources = Map Id ResourceInfo
- type Writable = Bool
- data ApiSpec = AS {}
- getPrimaryKey :: StructInfo -> Maybe Id
- isStructField :: FieldInfo -> Bool
- isStruct :: Type -> Bool
- strName :: Type -> String
- nonEmptyString :: Gen String
- generateRandomFieldInfo :: [Id] -> [Id] -> Gen FieldInfo
Documentation
A field modifier.
A field has a type, an identifier and a set of modifiers.
type StructInfo = [FieldInfo] Source
A struct is a list of fields.
type ResourceInfo = (Route, Writable) Source
A resource has a route and a write mode.
A type can be a primitive one (int, long, double, bool...), an enum, a struct, or a list of another type.
type Structs = [(Id, StructInfo)] Source
Map from struct id to its info.
type Resources = Map Id ResourceInfo Source
The spec of an api is a set of enums and structs, along with the resources.
AS | |
|
:: StructInfo | The info of the struct |
-> Maybe Id | The result (Nothing if there was no PK defined) |
Gets the primary key of a struct if it was specified.
isStructField :: FieldInfo -> Bool Source
Finds out if a fieldinfo is relative to a struct
nonEmptyString :: Gen String Source
Generates a non-empty arbitrary String
.