Skip to content
This repository
tree: a83913ba3e
Fetching contributors…

Cannot retrieve contributors at this time

file 104 lines (82 sloc) 3.87 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
Extra functions on types
*)


(**)

module Basic :
sig
  val string : QmlAst.ty
end

module Inspect :
sig
  (* Functions to unfold typenames (all subtly different) *)
  val find_and_specialize : QmlTypes.gamma -> QmlAst.typeident -> QmlAst.ty list -> QmlAst.ty
  (** if a typename is an alias give the type in alias definition *)
  val follow_alias : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty option

  (**
get the implementation of a types, traversing named types.
*)
  val follow_alias_noopt : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty

  (**
like [follow_alias_noopt] but traverse also private types.
*)
  val follow_alias_noopt_private : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty

  (* ************************************************************************ *)
  (* {b Descr}: Exception raised when a type contains a sub-term being a named
type defined as @private. The embedded type is the named type expression
whose named is bound to a @private type definition.
This is used when a toplevel value definition has a type in which a
@private type to the package appears and this definition is not marked
@private, hence is exported outside the package. Since the @private type
is not visible the toplevel definition must not be visible also. *)
  (* ************************************************************************ *)
  exception Escaping_private_type of QmlAst.ty

  (* ************************************************************************ *)
  (** {b Descr}: Ensures that no type private to the current package escapes,
i.e. appears in the type passed as argument. *)
  (* ************************************************************************ *)
  val check_no_private_type_escaping : QmlTypes.gamma -> QmlAst.ty -> unit

  (** if a type is an alias give follow the alias as a type list.
@raises QmlTyperException.Exception *)
  val get_deeper_type_until : QmlTypes.gamma -> (QmlAst.ty -> bool) -> QmlAst.ty -> QmlAst.ty

  (** for a typename, follow all alias until it gets the last typename,
for other types it is identity.
@raises QmlTyperException.Exception *)
  val get_deeper_typename : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty

  (* Other inspection functions *)
  val is_type_arrow : QmlTypes.gamma -> QmlAst.ty -> bool

  (**
See if the internal implementation of [ty] is the type [void].
*)
  val is_type_void : QmlTypes.gamma -> QmlAst.ty -> bool

  (**
See if the internal implementation of [ty] is the type [bool].
*)
  val is_type_bool : QmlTypes.gamma -> QmlAst.ty -> bool

  val get_arrow_params : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty list option
  val get_arrow_through_alias_and_private :
    QmlTypes.gamma -> QmlAst.ty -> (QmlAst.ty list * QmlAst.ty) option
end

(** Utils for arrow types *)
module TypeArrow : sig

  type 'a type_arrow_utils = QmlAst.ty list -> QmlAst.ty -> 'a

  (**
Returns the number of arguments of [ty] without distinction between a function
which returns a function and its curryfied version.
@see "nary_arity" for an example
@raise Invalid_argument if the [ty] is not a [TypeArrow]
*)
  val curryfied_arity : int type_arrow_utils
end
Something went wrong with that request. Please try again.