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 DA9D482355 for ; Tue, 28 Nov 2017 18:55:54 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ssp.mryau@gmail.com; spf=Pass smtp.mailfrom=ssp.mryau@gmail.com; spf=None smtp.helo=postmaster@mail-qt0-f182.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ssp.mryau@gmail.com) identity=pra; client-ip=209.85.216.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="ssp.mryau@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of ssp.mryau@gmail.com designates 209.85.216.182 as permitted sender) identity=mailfrom; client-ip=209.85.216.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="ssp.mryau@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-qt0-f182.google.com) identity=helo; client-ip=209.85.216.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ssp.mryau@gmail.com"; x-sender="postmaster@mail-qt0-f182.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Ax/FCiB1pDwyIDqBQsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?sesfI/ad9pjvdHbS+e9qxAeQG96Eu7QZ06L/iOPJZy8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL3WbmHC57CYTFxPjLkI1?= =?us-ascii?q?Y72tQs+Bx/iwgseZ8pjXKyBBhT68Z7w6CBStsU2FvcAThc5mK70t4hrPuHpBPe?= =?us-ascii?q?pMkzBGP1WWyi3x/Mi9tKVi7SdXpbp17NVYF6Dgbq0lZbNdBTUidWsy4Zu45lH4?= =?us-ascii?q?UQKT6y5EAS0tmR1SDl2AtUmiUw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0A3BQDkoR1af7bYVdFdHAEBARwBAQUBA?= =?us-ascii?q?YI3gRk0C24nB4N4gTaYAkMBAQEGiwyPKAoFFoohB0MUAQEBAQEBAQEBARIBAQk?= =?us-ascii?q?LCwgmMYI4BQEeAQWCZwQZARseAxIDBgc3AiQBEQEFARYMG4oBAQMIDYojjVaDR?= =?us-ascii?q?UCMEIFtGAUBHIMKBYNaChknDViCeAIGEoMqggmBDo4PgmMFikGIS489h3ONGoQ?= =?us-ascii?q?TjzyNf4gsFAUfgRY2gXMyGiOBAYF3CYIFglE3NokMgVgBAQE?= X-IPAS-Result: =?us-ascii?q?A0A3BQDkoR1af7bYVdFdHAEBARwBAQUBAYI3gRk0C24nB4N?= =?us-ascii?q?4gTaYAkMBAQEGiwyPKAoFFoohB0MUAQEBAQEBAQEBARIBAQkLCwgmMYI4BQEeA?= =?us-ascii?q?QWCZwQZARseAxIDBgc3AiQBEQEFARYMG4oBAQMIDYojjVaDRUCMEIFtGAUBHIM?= =?us-ascii?q?KBYNaChknDViCeAIGEoMqggmBDo4PgmMFikGIS489h3ONGoQTjzyNf4gsFAUfg?= =?us-ascii?q?RY2gXMyGiOBAYF3CYIFglE3NokMgVgBAQE?= X-IronPort-AV: E=Sophos;i="5.44,468,1505772000"; d="scan'208,217";a="246420493" Received: from mail-qt0-f182.google.com ([209.85.216.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 28 Nov 2017 18:55:53 +0100 Received: by mail-qt0-f182.google.com with SMTP id r39so897972qtr.13 for ; Tue, 28 Nov 2017 09:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=wLdddI2fcN2+uyOqlc+u3G+aZyV6x/k92Pj/vvydwN0=; b=dNkukncsqqp6HN6OTvmV6sRdWnNLBPkmwLpZZo+zLdKe/vHvmCXtq5NRdpcp6Y55Oj khnWlIBhkCVAD/2kEI7Hntj6JrlI/UhGUOqjKq34Qu7cRDr4CU/9/BoLV/NMndntT9W3 K+7Jqusy9pWq7OkHIQWek/EhC/Ka7kXaVtZaePxxFjyWhSbqRYqdDAROkZ7dURhjDYd0 llU+2y6TUetzEUFAaQKSDee6CoPMqttrOUmDxiEPP6/jHMGBojlEXi8+LYua98f3uJK/ YI4jP5ioDYiII18q+2aZiSR2uLoUH71aTCJrZsAMcH5uoxrpNWO+RfUg7l75iRnAMBMB Jb3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=wLdddI2fcN2+uyOqlc+u3G+aZyV6x/k92Pj/vvydwN0=; b=o4T7IcrRyz2aJZ5wkotbgp3f0s+Su9ss1LEHoawXq7/yFRTpl20yu4B6J8MuPj9Jmz R5Q8BQMYiJ8OwHs9/3odVPBAyrq9fsiDGQYlNenOT6maZwql86tBFhaNTNN3T0DfIcSe zuxb8Sw5Nzs3+VQUxeLt4LCXqf+vzguzw+h1eTgQo8HlOt8MScVnYee5tL61Fy9MJmIB V6CDJ1/Bx3j0pMdDy1ghdsjEpZIdj0VYcaoN7S+spPOLVI56vMBwsellDQ/kgbdelut/ yfwtHw1vpVaMDHtX86Lb27XLoMVU512Xjm/jmYL4GEqcYuhxjYLegjMK01QZK3g0yCB4 biwA== X-Gm-Message-State: AJaThX5+mQwEC90vJJ6+wvJl2BqSKpyTaJyUauhP3mzKHfRtQvZ9ZVJ6 W21rtlb+lGUyycvvRuNmZ0gvMGZi2Eiu72OA9fK/VA== X-Google-Smtp-Source: AGs4zMbmPqroFWG2b3biQOoHlMHJxog0wBTfGYEQjUCaAngTjfXhkV5rkPg9JbcIrrIZLs07yoZHLT0tdtK19BAtD04= X-Received: by 10.200.53.201 with SMTP id l9mr66630617qtb.155.1511891752161; Tue, 28 Nov 2017 09:55:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.40.209 with HTTP; Tue, 28 Nov 2017 09:55:51 -0800 (PST) From: Serge Sivkov Date: Tue, 28 Nov 2017 23:55:51 +0600 Message-ID: To: OCaml Mailing List Content-Type: multipart/alternative; boundary="001a114553f0d39443055f0eba4d" Subject: [Caml-list] using module with types as record parameter --001a114553f0d39443055f0eba4d Content-Type: text/plain; charset="UTF-8" Hello, is there way to fix the following code: module type CmdIface = sig type message val cmd : message -> unit end module type NetIface = sig type init val net : init -> init end module Cmd = struct type message = int let cmd v = v+1 end module Net = struct type init = { cvt: (module CmdIface) } let net init = let cvt = init.cvt in let module R = (val cvt: CmdIface) in R.cmd 1 (* line 22 with error *) end let i = { Net.cvt = (module Cmd: CmdIface) } Net.net i I got error: File "t.ml", line 22, characters 22-23: Error: This expression has type int but an expression was expected of type R.message In case I do not use types in function signature code works well: module type I = sig val f : int -> int end;; module M = struct let f v = v+1 end;; type t = {cvt: (module M); v: int};; let module R = (val i.cvt: I) in R.f i.v;; - : int = 1 WBR, ssp --001a114553f0d39443055f0eba4d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

is there way to fix the followin= g code:

module type CmdIface =3D sig
=C2=A0 =C2=A0 =C2=A0 =C2=A0 type message
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 val cmd : message -> unit
end

= module type NetIface =3D sig
=C2=A0 =C2=A0 =C2=A0 =C2=A0 type ini= t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 val net : init -> init
end

module Cmd =3D struct
=C2=A0 =C2=A0= =C2=A0 =C2=A0 type message =3D int
=C2=A0 =C2=A0 =C2=A0 =C2=A0 l= et cmd v =3D v+1
end

module Net =3D stru= ct
=C2=A0 =C2=A0 =C2=A0 =C2=A0 type init =3D { cvt: (module CmdIf= ace) }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 let net init = =3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 let c= vt =3D init.cvt in
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 let module R =3D (val cvt: CmdIface) in=C2=A0
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 R.cmd 1 (* line 22 with er= ror *)
end

let i =3D { Net.cvt =3D (modu= le Cmd: CmdIface) }
Net.net i

I go= t error:
File "t.ml", = line 22, characters 22-23:
Error: This expression has type int bu= t an expression was expected of type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0R.message

In case I do not use types i= n function signature code works well:
module type I =3D sig val f : int -> int end;;
module M =3D struct
let f v =3D v+1end;;
type t =3D {cvt: (module M); v: int};;
let module R =3D (val i= .cvt: I) in R.f i.v;;
- : int =3D 1

= WBR, ssp
--001a114553f0d39443055f0eba4d--