Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing identical types in OCAML

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.

like image 939
Aymon Fournier Avatar asked Mar 25 '11 21:03

Aymon Fournier


1 Answers

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.

like image 79
Michael Ekstrand Avatar answered Sep 24 '22 04:09

Michael Ekstrand