caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: rathereasy@gmail.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] type error
Date: Tue, 01 Apr 2008 11:42:34 +0900 (JST)	[thread overview]
Message-ID: <20080401.114234.146324100.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <f74178430803311927u3c1cbd2at8d30e6a85fb42d10@mail.gmail.com>

From: "Jacques Le Normand" <rathereasy@gmail.com>
> thanks for all the help so far; it's been very educational
> there's a type error I can't get my head around:
> 
> 
> class a =
> object
> end
> 
> and b =
> object
>   inherit a
>   method d (e : b) = (e :> a)
> end
> 
> 
> gives the error:
> 
> The abbreviation b expands to type < d : b -> a > but is used with type <  >
> 
> why is this?

You cannot coerce to a type that is not yet (fully) defined.
In practice, what happens is that (e :> a) is just interpreted as
(e : a), so that you are unifying a and b, with the above error.

As an exception to the above rule, you can coerce self toward the
currently defined class (i.e. coerce self to a inside a), but only if
self is covariant in itself. Here you coerce b to a inside b, so this
doesn't apply.

Jacques Garrigue


  reply	other threads:[~2008-04-01  2:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  2:27 Jacques Le Normand
2008-04-01  2:42 ` Jacques Garrigue [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-03-23 22:01 Jacques Le Normand
2008-03-23 22:19 ` [Caml-list] " Martin Jambon
2006-10-15  3:29 Type error Denis Bueno
2006-10-15  3:40 ` [Caml-list] " Jonathan Roewen
2006-10-15  3:48 ` skaller
2006-10-15  3:54 ` Jonathan Roewen
2006-10-15 11:26 ` Etienne Miret
2006-10-15 23:37 ` Jacques Garrigue
2005-04-02  1:29 Jon Harrop
2005-04-02  7:50 ` [Caml-list] " Jacques Garrigue

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=20080401.114234.146324100.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@yquem.inria.fr \
    --cc=rathereasy@gmail.com \
    /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).