Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 595

What is the right way to put type declarations in OCaml signatures

$
0
0

I have written the following two files, and although it works, it feels odd that the code would duplicate these long type declarations. On the other hand, if I remove either module type declaration then the code no longer compiles.

Is there a more proper way to write this kind of thing? Or is it correct to duplicate these type declarations in the .mli and .ml files?

set.mli

module type Element = sig  type t  val create : 'a -> t  val compare : t -> t -> int  val to_string : t -> stringendmodule type Set = sig  type t  val empty : unit -> tendmodule Make : functor (M : Element) -> Set with type t = M.t list

set.ml

module type Element = sig  type t  val create : 'a -> t  val compare : t -> t -> int  val to_string : t -> stringendmodule type Set = sig  type t  val empty : unit -> tendmodule Make (M:Element) = struct  type t = M.t list  let emtpy () = []end

Viewing all articles
Browse latest Browse all 595

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>