caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: bob zhang <bobzhang1988@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] This ground coercion is not principal?
Date: Thu, 10 Jan 2013 15:15:31 -0500	[thread overview]
Message-ID: <CANcqPu5B3m6Zs1AszNnryAZtG=4jAEPUwRo2hmbngzR7GfEUhQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

Hi List,
  I have came across a corner case in ocaml typing here,
The source code is pasted below(extracted from a large code base), it
triggers the warning 18.
My question, is there any elegant solution without introducing local types?

------------------------------------------------------------------------------------------
type ant = [`Ant of string]
type 'a mlist =
    [ `LNil
    | `LCons of ('a * 'a mlist )
    | ant]
let a = object(self)
  method ant : ant -> ant=
    fun (`Ant a)  ->
      `Ant a
  method mlist: 'all_a0 'all_b0 .
      ('self_type -> 'all_a0 -> 'all_b0) ->
        'all_a0 mlist -> 'all_b0 mlist=
          fun (type t) mf_a  ->
            function
              | `LNil ->  `LNil
              | `LCons (a0,a1) ->
                  let a0 = mf_a self a0 in
                  let a1 = self#mlist mf_a a1 in `LCons (a0, a1)
              | #ant as a0 -> (((* Obj.magic *) self#ant a0) :> (* 'all_b0
*) t mlist)
end






















-- 
Regards
-- Bob

[-- Attachment #2: Type: text/html, Size: 1671 bytes --]

             reply	other threads:[~2013-01-10 20:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 20:15 bob zhang [this message]
2013-01-10 21:06 ` Jeremie Dimino
2013-01-10 21:12   ` bob zhang
2015-02-25  4:47 [Caml-list] "this ground coercion is not principal" Martin DeMello
2015-02-25  9:29 ` Jeremie Dimino
2015-02-25 10:38 ` Jeremy Yallop
2015-02-25 21:35   ` Martin DeMello
2015-02-25 23:04     ` Jeremy Yallop

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='CANcqPu5B3m6Zs1AszNnryAZtG=4jAEPUwRo2hmbngzR7GfEUhQ@mail.gmail.com' \
    --to=bobzhang1988@gmail.com \
    --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).