Changing the same types in OCAML

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

How to make OCAML understand that these types are identically defined? I have several cases when I encountered this problem, since I started using the standard functions of the OCAML library.

+4
source share
1 answer

OCaml already knows that they are defined the same way - if you do not do something strange to hide types from abstraction, it will refer to StringSet.elt list and string list as the same type.

+6
source

Source: https://habr.com/ru/post/1345285/


All Articles