Dear Rémy,
The trouble here is that Hashtbl.S defines an abstract type for hash tables, and that each time you open this module, using the (module H : Hashtbl.S) pattern, your are talking about a fresh abstract type, incompatible with anything from the outside world. In particular, there is no way the parameter ht could have this type, and this causes an error.
Contrary to real functors, first-class modules do not let you connect abstract parameterized types with the outside world. So in this case, the only solution I see would be to pack your hash table inside the module itself, like for an object, so that you don't need to receive ht as a separate argument.
Jacques Garrigue
2015/06/16 21:16 "Rémy El Sibaïe Besognet" <remy.el-sibaie@lip6.fr>:Hi all,Considering this functionlet find ht x =Hashtbl.find ht x
I would like to write a more general `find` function which takes the moduleas first class module in parameter with the possibility to use it ondifferent implentations of Hashtbl.S.let find (module H : Hashtbl.S) ht x =H.find ht xbut it failed with this error (on the underlined identifier) :Error: This expression has type 'a H.t but an expression was expected of type'a H.tThe type constructor H.t would escape its scopeI also tried by specifying the implementation but had the same problem:let find (type a) (module H : Hashtbl.S with type key = a) (ht : 'a Ht.t) (x : a) =H.find ht xAnyone has an idea how to achieve this thing ?Thanks,- Rémy El Sibaïe, LIP6PS: at the begining, I was trying on a memoization function which has more interest than the previous function :let memo_rec (module H : Hashtbl.S) h f =let rec g x =try H.find h x with| Not_found ->let y = f g x inH.add h x y; yin g