caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien <Damien.Pous@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] 'b is unbound
Date: Wed, 12 May 2004 13:43:50 +0200	[thread overview]
Message-ID: <20040512134350.7be8c813.Damien.Pous@ens-lyon.fr> (raw)
In-Reply-To: <16545.50388.591926.577605@soggy.deldotd.com>

On Tue, 11 May 2004 23:31:48 -0700 briand@aracnet.com wrote:
 
> I'm getting the following error:
> 
>       method op :
>         (float, 'a, 'b) Bigarray.Array2.t ->
>         float array -> float array -> unit
>     end
> The method op has type
>   (float, 'a, 'b) Bigarray.Array2.t -> float array -> float array ->
>   unit
> where 'b is unbound
> 
> Is 'b really unbound, or is the inferencer simply unable to figure out
> what the type should be ?

polymorphic methods require to be explicitly typed
(this kind of type inference should lead to the one for system F)

# class o = object method id x = x end;;
Some type variables are unbound in this type:
  class o : object method id : 'a -> 'a end
The method id has type 'a -> 'a where 'a is unbound

# class o = object method id: 'a.'a -> 'a = fun x -> x end;;
class o : object method id : 'a -> 'a end
# let o = new o in o#id 5, o#id "toto";;
- : int * string = (5, "toto")


or maybe you want the whole class to be parametrized wrt 'a :

# class ['a] o = object method id (x:'a) = x end;;
class ['a] o : object method id : 'a -> 'a end
# let o = new o in o#id 5, o#id "toto";;
This expression has type string but is here used with type int

hope this helps,
damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-05-12 11:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-12  6:31 briand
2004-05-12 11:43 ` Damien [this message]
2004-05-12 19:11   ` briand
2004-05-13  2:54   ` briand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040512134350.7be8c813.Damien.Pous@ens-lyon.fr \
    --to=damien.pous@ens-lyon.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).