2 | import Data.SortedMap as Map
3 | import Data.Finite as Finite
4 | import Data.List.Elem
5 | import Data.List.Quantifiers
14 | Union: (types: List Type) -> Type
18 | BranchIndex: (a: Type) -> (types: List Type) -> Type
28 | interface Lana (schema: Type -> Type) where
29 | data Object: Type -> Type -> Type
30 | data Field: Type -> Type -> Type
31 | data AdditionalFields: Type -> Type -> Type
32 | data UnionMembers: List Type -> List Type -> Type
34 | schemaName : {a: Type} -> schema a -> Name
36 | double : schema Double
38 | text : schema String
40 | boolean : schema Bool
42 | array : schema a -> schema (List a)
46 | nullable : schema a -> schema (Either Null a)
56 | (object -> Maybe a) ->
58 | Field object (Maybe a)
66 | {object, a: Type} ->
67 | (object -> Map.SortedMap String a) ->
69 | AdditionalFields object (Map.SortedMap String a)
77 | {constructorType: Type} ->
79 | Object object constructorType
82 | {object, a, b: Type} ->
83 | Object object (a -> b) ->
88 | {object, a: Type} ->
89 | Object object (a -> object) ->
90 | AdditionalFields object a ->
91 | Object object object
96 | (b -> Either String a) ->
107 | {types: List Type} ->
109 | UnionMembers types types ->
110 | schema (Union types)
112 | unionMemberWithIndex :
114 | {types: List Type} ->
115 | BranchIndex a types ->
117 | UnionMembers types [a]
120 | {types, left, right: List Type} ->
121 | UnionMembers types left ->
122 | UnionMembers types right ->
123 | UnionMembers types (left ++ right)
129 | implementation Lana schema
=> Functor (Field object
) where
135 | {schema: Type -> Type} ->
136 | {object, a, b: Type} ->
138 | Object {schema} object (a -> b) ->
139 | Field {schema} object a ->
140 | Object {schema} object b
147 | {schema: Type -> Type} ->
148 | {types: List Type} ->
149 | {left, right: List Type} ->
151 | UnionMembers {schema} types left ->
152 | UnionMembers {schema} types right ->
153 | UnionMembers {schema} types (left ++ right)
160 | {schema: Type -> Type} ->
161 | {object, a: Type} ->
163 | Object {schema} object (a -> object) ->
164 | AdditionalFields {schema} object a ->
165 | Object {schema} object object