From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 334B07F02D for ; Tue, 21 Oct 2014 10:14:06 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 209.85.212.172 as permitted sender) identity=mailfrom; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f172.google.com) identity=helo; client-ip=209.85.212.172; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-wi0-f172.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuEBAI4ORlTRVdSslGdsb2JhbABchC4LBIMC0FwCgQcHFgERAQEBAQcLCwkSMIQDAQEEEhEEGQEbHQEDDAYFCw0CAiYCAiEBAREBBQEcBhMiiAgBAxGjH26LMIFygxCIbAoZJw1nhUcBAQEBAQUBAQEBARcBBQ6BHoxxgjQHgneBVAWbSYIRgTCOGIJZggwYKYUsPC+CSwEBAQ X-IPAS-Result: AuEBAI4ORlTRVdSslGdsb2JhbABchC4LBIMC0FwCgQcHFgERAQEBAQcLCwkSMIQDAQEEEhEEGQEbHQEDDAYFCw0CAiYCAiEBAREBBQEcBhMiiAgBAxGjH26LMIFygxCIbAoZJw1nhUcBAQEBAQUBAQEBARcBBQ6BHoxxgjQHgneBVAWbSYIRgTCOGIJZggwYKYUsPC+CSwEBAQ X-IronPort-AV: E=Sophos;i="5.04,760,1406584800"; d="scan'208";a="84044318" Received: from mail-wi0-f172.google.com ([209.85.212.172]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 21 Oct 2014 10:14:05 +0200 Received: by mail-wi0-f172.google.com with SMTP id bs8so256804wib.17 for ; Tue, 21 Oct 2014 01:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=J2t6gjUMhsCQ+lYP12Kib7OELsQTm8ki2+4U/MzfXc0=; b=z0YWpjr3LQ5IKn5H9YCMkHJ1R4FAFaaISQHwph2i5QKZd4tUgiIBEI73NE/NTg3YOT +bY96FudC3Ch8/Vfcv5wzjEIhM+6Fo6GyimF4Xc//wDX4xL6vnjQlGd+/qE1u6A0SUJc kjiEQZZMfmx5Oh16V6eDEBNe0GGAN0M559UszH37rh3iMPod0wAPkprYmjgXSaQ8zJwg Z3gEdXuttqaMk5ASYmN3m/AZb7QbAawYk+3f0oqmCZIJ83IzxgIbmZGASYgmtZCxTyuy dot9zg3l3xK0OkTRbzcJI2lkYcV+947J6QzW/KRv6a8NS0l+2nBfgfl2HhSWcwHYt/Mc ocOA== MIME-Version: 1.0 X-Received: by 10.194.222.162 with SMTP id qn2mr19178640wjc.74.1413879244635; Tue, 21 Oct 2014 01:14:04 -0700 (PDT) Received: by 10.217.115.5 with HTTP; Tue, 21 Oct 2014 01:14:04 -0700 (PDT) In-Reply-To: References: Date: Tue, 21 Oct 2014 09:14:04 +0100 Message-ID: From: Jeremy Yallop To: Thomas Braibant Cc: OCaML Mailing List Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] First class modules sub-typing On 21 October 2014 09:12, Jeremy Yallop wrote: > On 21 October 2014 08:49, Thomas Braibant 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)) or you can, of course, use the alias 't' to coerce: let test4 (type a) : a s -> string = fun t -> test1 (t :> t)