7.7 ローカル モジュール (Local modules)

let module module-name = module-expr in expr という式はローカルモジュールを表します。expr の中でだけ、module-name という識別子がモジュール module-expr に割り当てられます。expr を評価した値を返します。たとえば以下のように使います。

        let remove_duplicates comparison_fun string_list =
          let module StringSet =
            Set.Make(struct type t = string
                            let compare = comparison_fun end) in
          StringSet.elements
            (List.fold_right StringSet.add string_list StringSet.empty)