caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Florian Angeletti <octa@polychoron.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic variant subtyping riddle
Date: Thu, 5 Dec 2019 12:04:23 +0100	[thread overview]
Message-ID: <29e212ec-b7c5-ae14-66e9-090fe409c735@polychoron.fr> (raw)
In-Reply-To: <20191203215048.GA80518@mortimer.gmerlin.de>

Hi,

The meaningful difference here is that the type `safe` and `base` are 
recursive.

It is not particularly clear, but the second part of the error message 
is complaining about the difference of type in the argument of `List.

Typically, if your example is extended to:

     type safe = [ `A of safe | `B | `C ]
     type basic = [ `A of basic | `B ]
     let basic :basic = `A `B
     let of_safe :safe -> char = function
        | `A _ -> 'a'
        | `B -> 'b'
        | `C -> 'c'
     let relaxed = (of_safe : safe -> char :> [< safe ] -> char)
    let x = relaxed (basic :> safe)

Then the coercion becomes necessary too.

— octachron.



      reply	other threads:[~2019-12-05 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 21:50 Christopher Zimmermann
2019-12-05 11:04 ` Florian Angeletti [this message]

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=29e212ec-b7c5-ae14-66e9-090fe409c735@polychoron.fr \
    --to=octa@polychoron.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).