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 B67797EE33 for ; Mon, 13 Feb 2017 19:57:15 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=ivg@ieee.org; spf=Pass smtp.mailfrom=ivg@ieee.org; spf=None smtp.helo=postmaster@mail-it0-f46.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of ivg@ieee.org) identity=pra; client-ip=209.85.214.46; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of ivg@ieee.org designates 209.85.214.46 as permitted sender) identity=mailfrom; client-ip=209.85.214.46; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="ivg@ieee.org"; 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-it0-f46.google.com) identity=helo; client-ip=209.85.214.46; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="ivg@ieee.org"; x-sender="postmaster@mail-it0-f46.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A8yb8ChcUy944tuf/CwMvUvXtlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcu5Yh7h7PlgxGXEQZ/co6odzbGH7+axAidZuMnJmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6?= =?us-ascii?q?OPn+FJLMgMSrzeCy/IDYbxlViDanb75/KBq7oR/Vu8QYjoduN7s9xxnUqXZUZu?= =?us-ascii?q?pawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnF?= =?us-ascii?q?VguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hC?= =?us-ascii?q?oBKjU063/chNBug61HoRKhvx1/zJDSYIGJL/p1Y6fRccoHSWZdQspdUipMCZ6+?= =?us-ascii?q?YYQSFeoMJeRXr4f9qVUArhWwGBeiC//0xzBSmnP7x7c33/g9HQzE2gErAtIAsG?= =?us-ascii?q?7TrNXwLKocUv61w7POzT7ebv1W3iv96I/Wch89ofGMXK5wcdHMwkQoFgPFkFqQ?= =?us-ascii?q?pJfkPzyLyOsCrXKX7+16VeKgkmMqrRx6rDu3xso0lIXFmoYYxkrH+Ch52oo5O8?= =?us-ascii?q?C0RUFhbdOrEZZdsTyROZFsTcM4WW5ovT43yr0Ytp6/eygH0JEnyATea/yDaoSI?= =?us-ascii?q?4w7jWPqILTd2i39oeaizhxm18Uinxe38Ute73ExWoSpCl9nArnEN1xrN5cibUv?= =?us-ascii?q?Zx4Fut1DKV2w3Q6uxIO144mbfUJpI7zbM9l4IfsUHZES/3nEX2grWWdkIh+uWw?= =?us-ascii?q?6uTnfLrmq4SdN4BqlA7xLL4imsulAeQ3KgQORXSU+fyg1L3/+k30WKlFgeczkq?= =?us-ascii?q?ndqZzaIcUbprWlAwJOyYYi6xO/Dy+839gCnHkHKkhFeBOdgITzNVHOOqOwMfDq?= =?us-ascii?q?uEihnjlmwbj9O7rlAZyFemPGl7PidJ528AhXzxA1wNRboZ9YF+dSDuj0XxrQqt?= =?us-ascii?q?XeRjA+LwuqyObmFM41goIAVkqOD6KUdqTIvgnbtaoUP+CQadpN637GIP8/6qur?= =?us-ascii?q?1CdhlA=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0C0AACsAKJYhi7WVdFeDg0BAQEDAQEBC?= =?us-ascii?q?QEBARcBAQQBAQoBAYURB4NSnBSQCoc4hiICgWcHQhUBAQEBAQEBAQEBARIBAQE?= =?us-ascii?q?ICwsKHS+CMxsBghsBBAEjHQEBNwEECwsEBzcCAiISAQUBHAYTiV0FCKIkP4saa?= =?us-ascii?q?IF6K4MIAQEFiDkBAQEBAQUBAQEBAQEaCBKGOoRvh1qCX5BGizGSFJEFkU4UHoE?= =?us-ascii?q?VNV5EXgg9FwWEGiCBMlkiNQGKLAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0C0AACsAKJYhi7WVdFeDg0BAQEDAQEBCQEBARcBAQQBAQo?= =?us-ascii?q?BAYURB4NSnBSQCoc4hiICgWcHQhUBAQEBAQEBAQEBARIBAQEICwsKHS+CMxsBg?= =?us-ascii?q?hsBBAEjHQEBNwEECwsEBzcCAiISAQUBHAYTiV0FCKIkP4saaIF6K4MIAQEFiDk?= =?us-ascii?q?BAQEBAQUBAQEBAQEaCBKGOoRvh1qCX5BGizGSFJEFkU4UHoEVNV5EXgg9FwWEG?= =?us-ascii?q?iCBMlkiNQGKLAEBAQ?= X-IronPort-AV: E=Sophos;i="5.35,156,1484002800"; d="scan'208,217";a="213078908" Received: from mail-it0-f46.google.com ([209.85.214.46]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 13 Feb 2017 19:57:14 +0100 Received: by mail-it0-f46.google.com with SMTP id x75so16777675itb.0 for ; Mon, 13 Feb 2017 10:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JopRQRTpfIOTCuEEwOyajN92b+ulxu16AyW2PkCVj1o=; b=Ib6qsNW3vtj31OqU+e8hQYtmPGITIHhs1I8U56ku4L7plDZuv6TvaGYYId6ut1alj4 2FVKT+Z0YaF0x7zcoh21/ECmDsfSSvMVRjlcoyjxYK0XlRvFt3CQE3TyYOJ6U7O4LuZs 2jTgA4cWXoD9aKEcyElinVOopbXQluYxReQh5OL0w95n4Nuh+VS0+rjFiataaBlbjkI0 roefADSfUvuWrIcuUzQiGCxZQ0EYpW85eoONdb5cHyIEkPq755CxIvnH9HInz8cNdzaT fLvsa0DmCcO3X5tl/SivCdUb4ITdwN2lGbDvlJMqJI6D6YnDEGluig5NJrNLgMQPMCtU nX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JopRQRTpfIOTCuEEwOyajN92b+ulxu16AyW2PkCVj1o=; b=LIC7bT8JbC2E58nfCK8VxQlm6cKXioXFN1cfVNAh78uTM6Lr86GWDzH4BagijrSYsk RuZozFy927fOVsP9r9MzvLGHJZGcheaqmeqKVJGQOg35dXnywWQDwRDG/qmPC7/4utxW fonPhpNOCkfoqbLSieZWkuEQgZOkbUqu+L+hU6gOuXq1QjJD7YEy/lt0UGhBg3rW8ZNH ltu2E7LyE1Ay22UMifa3PLE5RUZkJyhsVPVajSuKBSMUtG4Ur7QRR0XCkl+AZno7xeOe Ji0eoRsy7NydWDDs8F8mc0XVApN34IBT0PY03l/ksVxglVVT+nYST+yNa6NpkvjpipAZ pUTQ== X-Gm-Message-State: AIkVDXKwWofa8Hm5scVVqp2tZL+GvqKr8YHVzgvhDksZuSJapGgBhqdWpsuqdhi4J/TmsWeg7RSfcB4Ci8cj3mIO X-Received: by 10.36.93.213 with SMTP id w204mr44411529ita.60.1487012232771; Mon, 13 Feb 2017 10:57:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.136.39 with HTTP; Mon, 13 Feb 2017 10:57:12 -0800 (PST) In-Reply-To: References: From: Ivan Gotovchits Date: Mon, 13 Feb 2017 13:57:12 -0500 Message-ID: To: Steffen Smolka Cc: Caml List Content-Type: multipart/alternative; boundary=001a113a6296e965aa05486e0307 Subject: Re: [Caml-list] private object constructor? --001a113a6296e965aa05486e0307 Content-Type: text/plain; charset=UTF-8 Hi Steffen, Your question contains the answer :) You can indeed expose an object type and a class type without exposing the class. module Example : sig class type t = object method print : unit end end = struct class t = object method print = print_endline "yep" end end The class implementation will not be exposed, so `new Example.t` will say `Unbound class Example.t`. But, the class type and object type will be exposed, e.g, you may say `type printable = Example.t` (yes, class type declaration declares both the type and the class type). Regards, Ivan On Mon, Feb 13, 2017 at 1:23 PM, Steffen Smolka wrote: > Hi, > > Is it possible to expose an object or class type in OCaml without exposing > the constructor, i.e. the ability to construct objects of the type? OCaml > supports private ADTs and type synonyms, but the private keyword doesn't > seem to work with classes or objects. > > Thanks, > -- Steffen > --001a113a6296e965aa05486e0307 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Steffen,

Your question contains the = answer=C2=A0:) You can indeed expose an object type and a class type withou= t exposing the class.

module Example : sig=C2= =A0
=C2=A0 class type t =3D object
=C2=A0 =C2=A0 =C2=A0= method print : unit
=C2=A0 =C2=A0 end=C2=A0
end =3D st= ruct=C2=A0
=C2=A0 =C2=A0 class t =3D object
=C2=A0 =C2= =A0 =C2=A0 method print =3D print_endline "yep"
=C2=A0 = =C2=A0 end=C2=A0
=C2=A0 end

The cl= ass implementation will not be exposed, so `new Example.t` will say `Unboun= d class Example.t`. But, the class type and object type will be exposed,
e.g, you may say `type printable =3D Example.t= ` (yes, class type declaration declares both the type and the class type).<= /div>

Regards,=
Ivan


On Mon, Feb 13, 2017 at 1:2= 3 PM, Steffen Smolka <smolka@cs.cornell.edu> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
Hi,

Is it possi= ble to expose an object or class type in OCaml without exposing the constru= ctor, i.e. the ability to construct objects of the type? OCaml supports pri= vate ADTs and type synonyms, but the private keyword doesn't seem to wo= rk with classes or objects.

Thanks,
-- Steffen

--001a113a6296e965aa05486e0307--