Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 105 lines (82 sloc) 3.87 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
19 (**
20 Extra functions on types
21 *)
22
23
24 (**)
25
26 module Basic :
27 sig
28 val string : QmlAst.ty
29 end
30
31 module Inspect :
32 sig
33 (* Functions to unfold typenames (all subtly different) *)
34 val find_and_specialize : QmlTypes.gamma -> QmlAst.typeident -> QmlAst.ty list -> QmlAst.ty
35 (** if a typename is an alias give the type in alias definition *)
36 val follow_alias : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty option
37
38 (**
39 get the implementation of a types, traversing named types.
40 *)
41 val follow_alias_noopt : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty
42
43 (**
44 like [follow_alias_noopt] but traverse also private types.
45 *)
46 val follow_alias_noopt_private : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty
47
48 (* ************************************************************************ *)
49 (* {b Descr}: Exception raised when a type contains a sub-term being a named
50 type defined as @private. The embedded type is the named type expression
aeb2974 @fpessaux [fix] OPA-555: Missing source location in error message for escaping …
fpessaux authored
51 whose named is bound to a @private type definition.
52 This is used when a toplevel value definition has a type in which a
53 @private type to the package appears and this definition is not marked
54 @private, hence is exported outside the package. Since the @private type
55 is not visible the toplevel definition must not be visible also. *)
fccc685 Initial open-source release
MLstate authored
56 (* ************************************************************************ *)
57 exception Escaping_private_type of QmlAst.ty
58
59 (* ************************************************************************ *)
60 (** {b Descr}: Ensures that no type private to the current package escapes,
61 i.e. appears in the type passed as argument. *)
62 (* ************************************************************************ *)
63 val check_no_private_type_escaping : QmlTypes.gamma -> QmlAst.ty -> unit
64
65 (** if a type is an alias give follow the alias as a type list.
66 @raises QmlTyperException.Exception *)
67 val get_deeper_type_until : QmlTypes.gamma -> (QmlAst.ty -> bool) -> QmlAst.ty -> QmlAst.ty
68
69 (** for a typename, follow all alias until it gets the last typename,
70 for other types it is identity.
71 @raises QmlTyperException.Exception *)
72 val get_deeper_typename : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty
73
74 (* Other inspection functions *)
75 val is_type_arrow : QmlTypes.gamma -> QmlAst.ty -> bool
76
77 (**
78 See if the internal implementation of [ty] is the type [void].
79 *)
80 val is_type_void : QmlTypes.gamma -> QmlAst.ty -> bool
81
82 (**
83 See if the internal implementation of [ty] is the type [bool].
84 *)
85 val is_type_bool : QmlTypes.gamma -> QmlAst.ty -> bool
86
87 val get_arrow_params : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty list option
834bf9f @fpessaux [cleanup] QmlTypesUtils: Non more used obscur functions.
fpessaux authored
88 val get_arrow_through_alias_and_private :
89 QmlTypes.gamma -> QmlAst.ty -> (QmlAst.ty list * QmlAst.ty) option
fccc685 Initial open-source release
MLstate authored
90 end
91
92 (** Utils for arrow types *)
93 module TypeArrow : sig
94
95 type 'a type_arrow_utils = QmlAst.ty list -> QmlAst.ty -> 'a
96
97 (**
98 Returns the number of arguments of [ty] without distinction between a function
99 which returns a function and its curryfied version.
100 @see "nary_arity" for an example
101 @raise Invalid_argument if the [ty] is not a [TypeArrow]
102 *)
103 val curryfied_arity : int type_arrow_utils
104 end
Something went wrong with that request. Please try again.