From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 CDAC0820A1 for ; Sun, 11 Aug 2013 03:55:17 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kosmo.zb@gmail.com) identity=pra; client-ip=209.85.217.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of kosmo.zb@gmail.com designates 209.85.217.181 as permitted sender) identity=mailfrom; client-ip=209.85.217.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="kosmo.zb@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-lb0-f181.google.com) identity=helo; client-ip=209.85.217.181; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kosmo.zb@gmail.com"; x-sender="postmaster@mail-lb0-f181.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AucFAJvtBlLRVdm1lGdsb2JhbABZhAusQJMwCBYOAQEBAQcLFBIqglIZATkDDQUQXRIBBQEiiBEDD5cXgwCPU4NxJw1XiAEBBQyURwOXZI9sFimBXYJlOw X-IPAS-Result: AucFAJvtBlLRVdm1lGdsb2JhbABZhAusQJMwCBYOAQEBAQcLFBIqglIZATkDDQUQXRIBBQEiiBEDD5cXgwCPU4NxJw1XiAEBBQyURwOXZI9sFimBXYJlOw X-IronPort-AV: E=Sophos;i="4.89,854,1367964000"; d="scan'208";a="23687875" Received: from mail-lb0-f181.google.com ([209.85.217.181]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 11 Aug 2013 03:55:17 +0200 Received: by mail-lb0-f181.google.com with SMTP id o10so4057670lbi.12 for ; Sat, 10 Aug 2013 18:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=CC4FZV2BKK+xqs8YU9BxnLD+kFX53YnOHl3vtDI4cuQ=; b=BOSQt64Yr7bWO17zdk9IL70msuQ6niX55WQR0T7XNOIJFCJ7ACCbNr8F7zraD3DSjw kvZmV+zupr1WRgpvpPd20grJbiBBLvoaFjm43l/0kQObFyuK+8RCPH/2GWCKYKMbwOm9 9O9Mcuo1EpwgijJfHY0JwZxxTewXXbRhXUbHs05wGoRKWOVwmdqmNopuqp+PIY4P0mag kwwtM/Zx86GNnxJwP3H85RIy7PwYnqm4o8+MwK37+Hor3MEvlJQf22DVSFDvbzLLmdiB Ctk1OC0EnBRg4hSSTsONMzjOal0Kk6niwkrfjfY1W+KPKSlgO2Cbg2TeN8SikdQV4YU2 shUQ== MIME-Version: 1.0 X-Received: by 10.112.51.101 with SMTP id j5mr2802129lbo.17.1376186116211; Sat, 10 Aug 2013 18:55:16 -0700 (PDT) Sender: kosmo.zb@gmail.com Received: by 10.112.61.130 with HTTP; Sat, 10 Aug 2013 18:55:16 -0700 (PDT) Date: Sun, 11 Aug 2013 02:55:16 +0100 X-Google-Sender-Auth: NM0qODV9nVvVdFh-LanVAPPmh0w Message-ID: From: David Sheets To: Caml List Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] First-class Functor Forgetting for Free What issue prevents functions over first-class modules from forgetting the first-class modules' type constraints? That is, given: ############### module type D = sig type t val x : t val f : t -> int end module type C = sig val q : int end module F(X : D) : C = struct let q = X.(f x) end let f x = let module X = (val x : D) in let module Q = struct let q = X.(f x) end in (module Q : C) let x = let module X = struct type t = int let x = 2 let f x = x * 3 end in (module X : D with type t = int) ;; let module X = (val x : D with type t = int) in let module M = F(X) in (* let x = (module (val x : D with type t = int) : D) in*) let module M' = (val f x : C) in Printf.printf "M.q is %d\n%!" M.q; Printf.printf "M'.q is %d\n%!" M'.q; () ############### Why must I uncomment (* let x = (module (val x : D with type t = int) : D) in*) to compile? I understand why structural subtyping requires a module cast but I don't see why type relaxation would. I looked at the generated assembly and this line seems to disappear. Why is it needed? Thanks, David