Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 219 lines (187 sloc) 12.497 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 open SurfaceAst
19 open QmlLoc (* brings annot into scope *)
20
21 module type IDENT =
22 sig
23 type ident
24 val equal : ident -> ident -> bool
25 val val_ : string -> ident
26 val typ : string -> ident
27 val fresh : unit -> ident (* typevar only *)
28 val ns_fresh : label:QmlLoc.annot -> string -> ident (* for any (expression) identifiers *)
29 end
30
31 module type CONS =
32 sig
33 type ident
34 type ident' = ident
35
36 module I : IDENT with type ident = ident'
37
38 (** @inline doc *)
39 (* Types *)
40 module T :
41 sig
42 val name : ?label:annot -> ?tyl:ident ty list -> string -> ident ty
43 val row_t : ?label:annot -> ?row:'a rowvar -> 'a fields_t_node -> 'a row_t
44 val args : ?label:annot -> ident ty list -> ident row_t
45 val arrow : ?label:annot -> ident ty list -> ident ty -> ident arrow_t
46 val arrow_1 : ?label:annot -> ident ty -> ident ty -> ident arrow_t
47 val arrow_2 : ?label:annot -> ident ty -> ident ty -> ident ty -> ident arrow_t
48
49 val external_ : ?label:annot -> unit -> ident ty
50
51 val typedef_node : ?tyvs:ident typevar list -> type_def_visibility -> ident -> ident ty -> ident typedef_node
52 val typedef : ?label:annot -> ?tyvs:ident typevar list -> type_def_visibility -> ident -> ident ty -> ident typedef
53
54 val typevar : ident -> ident typevar
55 val var : ?label:annot -> ident -> ident ty
56 val fresh : ?label:annot -> unit -> ident ty
57
58 val coerce : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> ident ty -> (ident, 'a) expr
59 val coerce_name : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> string -> (ident, 'a) expr
60
61 val record : ?label:annot -> ?row:ident rowvar -> ident fields_t_node -> ident ty
62 val tuple : ?label:annot -> ?row:ident rowvar -> ident ty list -> ident ty
63
64 val void : ?label:annot -> unit -> ident ty
65 val string : ?label:annot -> unit -> ident ty
66 val int : ?label:annot -> unit -> ident ty
67 val float : ?label:annot -> unit -> ident ty
68 val bool : ?label:annot -> unit -> ident ty
69 end
70
71 (* Patterns *)
72 (** @inline doc *)
73 module P :
74 sig
75 val coerce : ?label:annot -> ident pat -> ident ty -> ident pat
76 val coerce_name : ?label:annot -> ident pat -> string -> ident pat
77
78 val any : ?label:annot -> unit -> ident pat
79 val ident : ?label:annot -> ident -> ident pat
80 val var : ?label:annot -> ident -> ident pat
81
82 val string : ?label:annot -> string -> ident pat
83
84 val record : ?label:annot -> ?row:bool -> ident pat_record_node -> ident pat
85 val record1 : ?label:annot -> string -> ident pat -> ident pat
86 val simple_record : ?label:annot -> string -> ident pat
87 val tuple : ?label:annot -> ident pat list -> ident pat
88 val tuple_2 : ?label:annot -> ident pat -> ident pat -> ident pat
89
90 val void : ?label:annot -> unit -> ident pat
91 val true_ : ?label:annot -> unit -> ident pat
92 val false_ : ?label:annot -> unit -> ident pat
93 val bool : ?label:annot -> bool -> ident pat
94 val cons : ?label:annot -> ident pat -> ident pat -> ident pat
95 val nil : ?label:annot -> unit -> ident pat
96 val hd_tl : ?label:annot -> ident pat -> ident pat -> ident pat
97 val list : ?label:annot -> ident pat list -> ident pat
98 val none : ?label:annot -> unit -> ident pat
99 val some : ?label:annot -> ident pat -> ident pat
100 end
101
102 (* Expressions *)
103 (** @inline doc *)
104 module E :
105 sig
106 val coerce : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> ident ty -> (ident, 'a) expr
107 val coerce_name : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> string -> (ident, 'a) expr
108
109 val record : ?label:annot -> (ident, 'a) record_node -> (ident, 'a) expr
110 val simple_record : ?label:annot -> string -> ('a, [< all_directives > `coerce ]) expr
111 val record1 : ?label:annot -> string -> (ident, 'a) expr -> (ident, 'a) expr
112 val tuple : ?label:annot -> (ident, 'a) expr list -> (ident, 'a) expr
113 val tuple_2 : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
114
115 val constant : ?label:annot -> const_expr_node -> (ident, _) expr
116 val string : ?label:annot -> string -> (ident, _) expr
117 val float : ?label:annot -> float -> (ident, _) expr
118 val big_int : ?label:annot -> Big_int.big_int -> (ident, _) expr
119 val int : ?label:annot -> int -> (ident, _) expr
120
121 val ident : ?label:annot -> ident -> (ident, _) expr
122 val var : ?label:annot -> ident -> (ident, _) expr
123
124 val void : ?label:annot -> unit -> ('a, [< all_directives > `coerce ]) expr
125 val true_ : ?label:annot -> unit -> (ident, [< all_directives > `coerce ]) expr
126 val false_ : ?label:annot -> unit -> (ident, [< all_directives > `coerce ]) expr
127 val bool : ?label:annot -> bool -> (ident, [< all_directives > `coerce ]) expr
128 val cons : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
129 val nil : ?label:annot -> unit -> (ident, [< all_directives > `coerce ]) expr
130 val list : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr list -> (ident, 'a) expr
131 val none : ?label:annot -> unit -> (ident, [< all_directives > `coerce ]) expr
132 val some : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr
133
134 val dot : ?label:annot -> (ident, 'a) expr -> string -> (ident, 'a) expr
135
136 val lambda : ?label:annot -> ident pat list -> (ident, 'a) expr -> (ident, 'a) expr
137 val lambda_var : ?label:annot -> ident -> (ident, 'a) expr -> (ident, 'a) expr
138 val lambda_ignore : ?label:annot -> (ident, 'a) expr -> (ident, 'a) expr
139 val lambda_void : ?label:annot -> (ident, 'a) expr -> (ident, 'a) expr
140 val applys : ?label:annot -> (ident, 'a) expr -> (ident, 'a) expr list -> (ident, 'a) expr
141 val apply : ?label:annot -> (ident, 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
142 val apply2 : ?label:annot -> (ident, 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
143 val apply_void : ?label:annot -> (ident, ([> `coerce ] as 'a)) expr -> (ident, 'a) expr
144 val eta_expand : ?label:annot -> int -> (ident, 'a) expr -> (ident, 'a) expr
145
146 val match_ : ?label:annot -> (ident, 'a) expr -> (ident pat * (ident, 'a) expr) list -> (ident, 'a) expr
147 val if_ : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
148 val if_then : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
149 val if_not : ?label:annot -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
150 val match_opt : ?label:annot -> ?ty:ident ty -> (ident, [< all_directives > `coerce ] as 'a) expr -> ident pat * (ident, 'a) expr ->
151 ident pat * (ident, 'a) expr -> (ident, 'a) expr
152 val match_option : ?label:annot -> ?ty:ident ty -> (ident, [< all_directives > `coerce ] as 'a) expr -> (ident, 'a) expr ->
153 (ident -> (ident, 'a) expr) -> (ident, 'a) expr
154
155 val letgen : ?label:annot -> rec_:bool -> (ident * (ident, 'a) expr) list -> (ident, 'a) expr -> (ident, 'a) expr
156 val letrec : ?label:annot -> (ident * (ident, 'a) expr) list -> (ident, 'a) expr -> (ident, 'a) expr
157 val letand : ?label:annot -> (ident * (ident, 'a) expr) list -> (ident, 'a) expr -> (ident, 'a) expr
158 val letin : ?label:annot -> ident -> (ident, 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
159 val letins : ?label:annot -> (ident * (ident, 'a) expr) list -> (ident, 'a) expr -> (ident, 'a) expr
160 val bypass : ?label:annot -> string -> (ident, 'a) expr
161 end
162
163 (* Directives *)
164 (** @inline doc *)
165 module D :
166 sig
167 (* directives types *)
168 (** @inline doc *)
169 module T :
170 sig
171 val static_source_content : ?label:annot -> unit -> ident arrow_t
172 val static_include_directory : ?label:annot -> unit -> ident arrow_t
173 val static_binary_content : ?label:annot -> unit -> ident arrow_t
174 val assert_message : ?label:annot -> unit -> ident arrow_t
175 val ensure_message : ?label:annot -> unit -> ident arrow_t
176 val deprecated : ?label:annot -> unit -> ident arrow_t
177 val warning : ?label:annot -> unit -> ident arrow_t
178 val assert_ : ?label:annot -> unit -> ident arrow_t
179 val client : ?label:annot -> unit -> ident arrow_t
180 val server : ?label:annot -> unit -> ident arrow_t
181 val ensure : ?label:annot -> unit -> ident arrow_t
182 val fail : ?label:annot -> unit -> ident arrow_t
183 val force : ?label:annot -> unit -> ident arrow_t
184 val private_ : ?label:annot -> unit -> ident arrow_t
185 val protected : ?label:annot -> unit -> ident arrow_t
186 val slicer : ?label:annot -> unit -> ident arrow_t
187 val translate : ?label:annot -> unit -> ident arrow_t
188 val unsafe_cast : ?label:annot -> unit -> ident arrow_t
189 val spawn : ?label:annot -> unit -> ident arrow_t
190 val lazy_ : ?label:annot -> unit -> ident arrow_t
191 val magic_to_string : ?label:annot -> unit -> ident arrow_t
192 val magic_to_xml : ?label:annot -> unit -> ident arrow_t
193 val side_annotation : ?label:annot -> unit -> ident arrow_t
194 val visibility_annotation : ?label:annot -> unit -> ident arrow_t
195 end
196 (* directive expressions *)
197 val open_ : ?label:annot -> (ident, [< all_directives > `open_ ] as 'a) expr -> (ident, 'a) expr -> (ident, 'a) expr
198 val doctype : string list -> ?label:annot -> ?access:SurfaceAst.access_directive -> (ident, [< all_directives > `doctype ] as 'a) expr -> (ident, 'a) expr
199 val side_annotation : ?label:annot -> [`server | `client | `both | `prefer_server | `prefer_client | `prefer_both | `both_implem ] ->
200 (ident, [< all_directives > `side_annotation] as 'a) expr -> (ident,'a) expr
201 val visibility_annotation : ?label:annot -> [`public of [`sync | `async | `funaction] | `private_] -> (ident, [< all_directives > `visibility_annotation] as 'a) expr -> (ident,'a) expr
202 val static_content : ?label:annot -> ?factory_helper:(ident, 'a) expr -> bool -> string -> (ident, [> `static_content of (string * bool) ] as 'a) expr
203 val static_resource: ?label:annot -> ?factory_helper:(ident, 'a) expr -> string -> (ident, [> `static_resource of string ] as 'a) expr
204 val server_entry_point : ?label:annot -> (ident, [> `server_entry_point ] as 'a) expr -> (ident, 'a) expr
205 end
206
207 (* code element *)
208 (** @inline doc *)
209 module C :
210 sig
211 val newval_pel : ?rec_:bool -> ?label:annot -> (ident pat * (ident, 'a) expr) list -> (ident, 'a) code_elt
212 val newval : ?label:annot -> ident -> (ident, 'a) expr -> (ident, 'a) code_elt
213 val newvalrec : ?label:annot -> ident -> (ident, 'a) expr -> (ident, 'a) code_elt
214 val newval_ignore : ?label:annot -> (ident, 'a) expr -> (ident, 'a) code_elt
215 val newtype : ?label:annot -> ident typedef -> (ident, _) code_elt
216 end
217
218 end
Something went wrong with that request. Please try again.