5

Suppose I have a function list_fun : int_list -> string list and in that function I use a StringSet that I define as module StringSet = Set.Make(String). I try to have the function return Set.elements s and get a string list but instead I get a StringSet.elt list which is supposed to be the same thing, as the StringSet's type t = string

How do you make OCaml understand that these types are identically defined? I have several cases where I have come across this issue as I have started using the OCaml standard library functions.

Chris
  • 26,361
  • 5
  • 21
  • 42
Aymon Fournier
  • 4,323
  • 12
  • 42
  • 59

1 Answers1

7

OCaml already knows that they are identically defined - unless you're doing something strange to hide the types behind an abstraction, it will treat a StringSet.elt list and string list as the same type.

Chris
  • 26,361
  • 5
  • 21
  • 42
Michael Ekstrand
  • 28,379
  • 9
  • 61
  • 93