From: Jeremy Yallop <yallop@gmail.com>
To: Thomas Braibant <thomas.braibant@gmail.com>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] First class modules sub-typing
Date: Tue, 21 Oct 2014 09:12:57 +0100 [thread overview]
Message-ID: <CAAxsn=GqyZXBPBtSkdQ33j0nnz9HZxGkosCRRXXG7mvQeJq7sg@mail.gmail.com> (raw)
In-Reply-To: <CAHR=VkzsbRrPEqi3bg3Zk3oQHAthgrtdOuK9uM0J6846pUFyFQ@mail.gmail.com>
On 21 October 2014 08:49, Thomas Braibant <thomas.braibant@gmail.com> wrote:
> I am slightly puzzled by a type-error related to first class modules.
> I am basically defining two types (see full example below)
>
> ```
> type t = (module A)
> type 'a s = (module A with type I.t = 'a)
> ```
>
> and I expect a value of type `'a s` can be coerced to a value of type
> t. However, this is obviously not the case because I get the following
> error message, and I wonder why.
Conversions between first class module types need explicit coercions.
It's sufficient to change your test4 function as follows:
> let test4 (type a) : a s -> string = fun t -> test1 t
let test4 (type a) : a s -> string = fun t -> test1 (t :> (module A))
next prev parent reply other threads:[~2014-10-21 8:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 7:49 Thomas Braibant
2014-10-21 8:12 ` Jeremy Yallop [this message]
2014-10-21 8:14 ` 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='CAAxsn=GqyZXBPBtSkdQ33j0nnz9HZxGkosCRRXXG7mvQeJq7sg@mail.gmail.com' \
--to=yallop@gmail.com \
--cc=caml-list@inria.fr \
--cc=thomas.braibant@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