Permalink
Browse files

[feature] compiler, utils: Added get_data_type_of_map

  • Loading branch information...
1 parent b180ef1 commit bb01c2caf3421c83b3f4a88162ea2040fef85a76 @BourgerieQuentin BourgerieQuentin committed May 23, 2012
Showing with 9 additions and 0 deletions.
  1. +5 −0 libqmlcompil/qmlTypesUtils.ml
  2. +4 −0 libqmlcompil/qmlTypesUtils.mli
@@ -250,6 +250,11 @@ struct
match follow_alias_noopt gamma ty with
| Q.TypeArrow (tl, t2) -> Some (tl,t2)
| _ -> None
+
+ let get_data_type_of_map gamma ty =
+ match follow_alias_noopt_private ~until:"ordered_map" gamma ty with
+ | Q.TypeName ([_; dty; _], _) -> dty
+ | _ -> raise Not_found
end
module TypeArrow =
@@ -87,6 +87,10 @@ sig
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
+
+ (** Returns the type of data of the [ty] map. If the given [ty] is not a type
+ of map (or an alias) throws [Not_found].*)
+ val get_data_type_of_map : QmlTypes.gamma -> QmlAst.ty -> QmlAst.ty
end
(** Utils for arrow types *)

0 comments on commit bb01c2c

Please sign in to comment.