If you really need names with polymorphic types,
then their definitions should be changed. The most simple way to do this
is to encapsulate the faulty names together in a local definition.
For instance, to make a polymorphic reference cell, write the
following refcell.j file:
let ref(s0) =
let get() | state(s) = state(s) | reply s to get
and set(s) | state(t) = state(s) | reply to set in
state(s0) | reply get,set to refcell
;;
Then both names get and set are packed together as a result of an
invocation of refcell and their common type variable is generalized
when the type of refcell is generalized.
# jcc -i refcell.j -c
val ref : <'a> -> <<> -> <'a> * <'a> -> <>>
To use get and set from another module, you will have to create
fresh reference cells, thereby creating two fresh instances of
get and set:
let gi,si = refcell.ref(0)
;;
let gs,ss = refcell.ref("")
;;
The jcc -i output for compiling this file is:
val gi : <> -> <int>
val si : <int> -> <>
val gs : <> -> <string>
val ss : <string> -> <>