why do i have to repeat so much here?

"Martin DeMello [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAFrFfuE7LfsFGjBfC6Ft0mh0MCYSBjep75AVcWjHDy0g4q0bbQ@mail.gmail.com>
I'm learning my way around the module system, and trying to write a small
Environment module that creates a record based on a given type. My code
works, but it looks like i had to essentially write out the record
definition thrice. Is there a better way to do this?

Here's the definition of the module

/--------------------------------
$ cat environment.mli

module type ENV = sig
  type dict

  type env = {
    dict : dict;
    op : Types.uop
  }
end

module Make (Dict : sig type t end) : ENV with type dict = Dict.t

$ cat environment.ml

module type ENV = sig
  type dict

  type env = {
    dict : dict;
    op : Types.uop
  }
end

module Make (Dict : sig type t end) = struct
  type dict = Dict.t

  type env = {
    dict : dict;
    op : Types.uop
  }
end

\--------------------------------

and I'm using it in the following code:

/--------------------------------
module Evaluator =
  functor (Env : ENV) ->
  functor (E : ENGINE with type dict = Env.dict) ->
  struct ... end

module Env = Environment.Make (Trie)

module Eval = Evaluator.Evaluator (Env) (TrieEngine)
\--------------------------------

martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.