| Newsgroups |
gmane.comp.lang.ocaml.beginners |
| Message-ID |
<[email protected]> |
I have some let definitions binding some functions to function references. This works nicely, but the typing system is giving me some hell about "type variables that cannot be generalized"; in my edits to the to promote the list type to a Core list, I have to provide type parameters the module constructors. This works fine so far, but now I have to have a declared reference that can be updated; it seems that I can't declare it raw, however:
let my_func obj = assert false
...
let my_func = ref my_func
At the rebinding, let my_func becomes a type issue with:
Error: The type of this expression, (<type> -> <type>) ref, contains type variables that cannot be generalized
I don't know how to just get the compiler to accept that my_func is a function reference, and to allow it's declaration. Literally I can't do anything regarding just adding a () parameter, because then I'm not binding a value, I'm binding the function that returns a reference; you can't update that, because the function reference returned in each of the implementing modules that edit these such references is local to that executing scope-it's not the reference instance we want.
How can I either get the compiler to accept such a function reference?