Re: Function Reference Issues

"Kenneth Miller [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
So I have to use a specific type, I can't qualify it with 'a, 'b; int, int would work?
I don't know what specific types are used for 'a and 'b... 
I think that maybe just removing this reference usage would be the best approach because of that, but when the whole reason the references were introduced in this project was to answer some interdependence issues; module A defines some type conversion functions as far definitions everyone else can use, modules B, C, D... all implement said conversion function and subsequently are updating the mentioned reference in module A. The issue is that B, C, D depend on A, but A needs that one function from B, C, D...
Does anybody have any advice regarding how to restructure for interdependence so that this can be solved? 


     On Thursday, June 25, 2015 12:26 PM, "Sebastien Mondet [email protected] [ocaml_beginners]" <[email protected]> wrote:
   

     A “top-level” reference should not contain things with unbound type
variables (in a module declaration).

let my_func obj = assert false
has type 'a -> 'b (→ 2 type variables)

If you want that reference you should force a "final" type, like:

let my_func_ref : (int -> unit) ref = ref my_func

On Thu, Jun 25, 2015 at 12:12 PM, Kenneth Miller
[email protected] [ocaml_beginners]
<[email protected]> wrote:
>
>
> 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?
>
>
>
> 
  #yiv1880492581 #yiv1880492581 -- #yiv1880492581ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv1880492581 #yiv1880492581ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv1880492581 #yiv1880492581ygrp-mkp #yiv1880492581hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv1880492581 #yiv1880492581ygrp-mkp #yiv1880492581ads {margin-bottom:10px;}#yiv1880492581 #yiv1880492581ygrp-mkp .yiv1880492581ad {padding:0 0;}#yiv1880492581 #yiv1880492581ygrp-mkp .yiv1880492581ad p {margin:0;}#yiv1880492581 #yiv1880492581ygrp-mkp .yiv1880492581ad a {color:#0000ff;text-decoration:none;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ygrp-lc {font-family:Arial;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ygrp-lc #yiv1880492581hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ygrp-lc .yiv1880492581ad {margin-bottom:10px;padding:0 0;}#yiv1880492581 #yiv1880492581actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv1880492581 #yiv1880492581activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv1880492581 #yiv1880492581activity span {font-weight:700;}#yiv1880492581 #yiv1880492581activity span:first-child {text-transform:uppercase;}#yiv1880492581 #yiv1880492581activity span a {color:#5085b6;text-decoration:none;}#yiv1880492581 #yiv1880492581activity span span {color:#ff7900;}#yiv1880492581 #yiv1880492581activity span .yiv1880492581underline {text-decoration:underline;}#yiv1880492581 .yiv1880492581attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv1880492581 .yiv1880492581attach div a {text-decoration:none;}#yiv1880492581 .yiv1880492581attach img {border:none;padding-right:5px;}#yiv1880492581 .yiv1880492581attach label {display:block;margin-bottom:5px;}#yiv1880492581 .yiv1880492581attach label a {text-decoration:none;}#yiv1880492581 blockquote {margin:0 0 0 4px;}#yiv1880492581 .yiv1880492581bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv1880492581 .yiv1880492581bold a {text-decoration:none;}#yiv1880492581 dd.yiv1880492581last p a {font-family:Verdana;font-weight:700;}#yiv1880492581 dd.yiv1880492581last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv1880492581 dd.yiv1880492581last p span.yiv1880492581yshortcuts {margin-right:0;}#yiv1880492581 div.yiv1880492581attach-table div div a {text-decoration:none;}#yiv1880492581 div.yiv1880492581attach-table {width:400px;}#yiv1880492581 div.yiv1880492581file-title a, #yiv1880492581 div.yiv1880492581file-title a:active, #yiv1880492581 div.yiv1880492581file-title a:hover, #yiv1880492581 div.yiv1880492581file-title a:visited {text-decoration:none;}#yiv1880492581 div.yiv1880492581photo-title a, #yiv1880492581 div.yiv1880492581photo-title a:active, #yiv1880492581 div.yiv1880492581photo-title a:hover, #yiv1880492581 div.yiv1880492581photo-title a:visited {text-decoration:none;}#yiv1880492581 div#yiv1880492581ygrp-mlmsg #yiv1880492581ygrp-msg p a span.yiv1880492581yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv1880492581 .yiv1880492581green {color:#628c2a;}#yiv1880492581 .yiv1880492581MsoNormal {margin:0 0 0 0;}#yiv1880492581 o {font-size:0;}#yiv1880492581 #yiv1880492581photos div {float:left;width:72px;}#yiv1880492581 #yiv1880492581photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv1880492581 #yiv1880492581photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv1880492581 #yiv1880492581reco-category {font-size:77%;}#yiv1880492581 #yiv1880492581reco-desc {font-size:77%;}#yiv1880492581 .yiv1880492581replbq {margin:4px;}#yiv1880492581 #yiv1880492581ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv1880492581 #yiv1880492581ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv1880492581 #yiv1880492581ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv1880492581 #yiv1880492581ygrp-mlmsg select, #yiv1880492581 input, #yiv1880492581 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv1880492581 #yiv1880492581ygrp-mlmsg pre, #yiv1880492581 code {font:115% monospace;}#yiv1880492581 #yiv1880492581ygrp-mlmsg * {line-height:1.22em;}#yiv1880492581 #yiv1880492581ygrp-mlmsg #yiv1880492581logo {padding-bottom:10px;}#yiv1880492581 #yiv1880492581ygrp-msg p a {font-family:Verdana;}#yiv1880492581 #yiv1880492581ygrp-msg p#yiv1880492581attach-count span {color:#1E66AE;font-weight:700;}#yiv1880492581 #yiv1880492581ygrp-reco #yiv1880492581reco-head {color:#ff7900;font-weight:700;}#yiv1880492581 #yiv1880492581ygrp-reco {margin-bottom:20px;padding:0px;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ov li a {font-size:130%;text-decoration:none;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv1880492581 #yiv1880492581ygrp-sponsor #yiv1880492581ov ul {margin:0;padding:0 0 0 8px;}#yiv1880492581 #yiv1880492581ygrp-text {font-family:Georgia;}#yiv1880492581 #yiv1880492581ygrp-text p {margin:0 0 1em 0;}#yiv1880492581 #yiv1880492581ygrp-text tt {font-size:120%;}#yiv1880492581 #yiv1880492581ygrp-vital ul li:last-child {border-right:none !important;}#yiv1880492581
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.