I can write my own extension for List
module of OCaml, by defining a file lib.ml
and including List
module:
module List =
struct
include List
(* remove l x returns the list l without the first element x found or *)
(* returns l if no element is equal to x. *)
(* Elements are compared using ( = ). *)
let rec remove (l : 'a list) (x : 'a) : 'a list =
match l with
| [] -> []
| hd :: tl ->
if hd = x then
tl else
hd :: remove tl x
...
end
Then I can call Lib.List.remove ...
in other files.
Now I would like to write my own extension for Map.Make
functor, I tried something like follows in lib.ml
:
module Make (Ord : Map.OrderedType with type key = Ord.t) =
struct
include Map.Make(Ord)
let aaa = 1
end
However, the compilation gives an error Error: The signature constrained by 'with' has no component named key
.
Does anyone know how to do it?