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 C9E197FC6B for ; Mon, 19 Oct 2015 18:58:58 +0200 (CEST) IronPort-PHdr: 9a23:1KT5mxa3Zn4+uzKUDqKgLYj/LSx+4OfEezUN459isYplN5qZpcm6bnLW6fgltlLVR4KTs6sC0LqK9fG+EjVZud6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDuvcyNKFwR3HKUWvBbElaflU3prM4YgI9veO4a6yDihT92QdlQ3n5iPlmJnhzxtY+a9Z9n9DlM6bp6r5YTGfayQ6NtapdRCTBuZ2s84cmusRjYUSOO4GEdWyMYiEwbLRLC6UTBRpbrtTCym+583zGdIMnxVvhgQjmm7qBzTwLAhyIONjp/+2bS3J8jxJlHqQ6s8kQsi7XfZ5uYYaJz Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=seliopou@gmail.com; spf=Pass smtp.mailfrom=seliopou@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f43.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of seliopou@gmail.com) identity=pra; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="seliopou@gmail.com"; x-sender="seliopou@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of seliopou@gmail.com designates 209.85.215.43 as permitted sender) identity=mailfrom; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="seliopou@gmail.com"; x-sender="seliopou@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-lf0-f43.google.com) identity=helo; client-ip=209.85.215.43; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="seliopou@gmail.com"; x-sender="postmaster@mail-lf0-f43.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CeAwC1ICVWlCvXVdFehHkGqwOGdowSAQGBZIdUBz0PAQEBAQEBAQEQAQEBAQcLCwkfMIImgiARBBkBGx4DEgkBBjcCJAERAQUBIjWHeAEDEqFQggiBMT4xi0mBbIJ5iCoKGScNVoRNAQUOhmmMe4FFBZYjjR2aTBIjgRc5AQEBgk6BeCI0hWcBAQE X-IPAS-Result: A0CeAwC1ICVWlCvXVdFehHkGqwOGdowSAQGBZIdUBz0PAQEBAQEBAQEQAQEBAQcLCwkfMIImgiARBBkBGx4DEgkBBjcCJAERAQUBIjWHeAEDEqFQggiBMT4xi0mBbIJ5iCoKGScNVoRNAQUOhmmMe4FFBZYjjR2aTBIjgRc5AQEBgk6BeCI0hWcBAQE X-IronPort-AV: E=Sophos;i="5.17,702,1437429600"; d="scan'208";a="151060516" Received: from mail-lf0-f43.google.com ([209.85.215.43]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 19 Oct 2015 18:58:57 +0200 Received: by lffv3 with SMTP id v3so115444342lff.0 for ; Mon, 19 Oct 2015 09:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=IeMJDzxcX/ymx3YdjLTg1WGe1PLI2Et/hFdJN+yo9+o=; b=VJ3FIAbNUv9aR7x6A5zuc96+JQv29792axZYwxVg1nX4tA2ojAy4oh6AwIR/stiuYd UeVnprnROK4fWkC0bfEdVNBHo1c5AtDsNna6bQAME507hJjavkk0zEt07L8nzcmcz+37 0QTNIFtS2fPQdV74rkbXUFUXtpu/bcG57vcow09kD52Vo5iITLIOtAYxHvnu+IS6e6vr fP2UvQYuBnl76yRBDN+pmWaS9aTJbUbYMvsBlGxLpQoykJL+kiuQn/y4rxC8kkqkh3kQ QE7WuDt+us3cV/rCYcUAG25HRZjNzXr+C9rxEEHq+UqVDf7xujvspB7koz8HCM85JQms rBuA== X-Received: by 10.25.169.68 with SMTP id s65mr10277422lfe.78.1445273937353; Mon, 19 Oct 2015 09:58:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.213.2 with HTTP; Mon, 19 Oct 2015 09:58:37 -0700 (PDT) From: Spiros Eliopoulos Date: Mon, 19 Oct 2015 12:58:37 -0400 Message-ID: To: OCaml Content-Type: multipart/alternative; boundary=001a11411dcaa3a3520522780f1b Subject: [Caml-list] "map"-ing parameterized class types --001a11411dcaa3a3520522780f1b Content-Type: text/plain; charset=UTF-8 Hey List, I'm trying to create a "container" class[0] that can store a value of type 'a, and transform that value to another value of type 'b. I'm trying to do this by including a "map" method in the container that applies a function to the value and returns a new instance of container with the transformed value. Despite the annotations, the types aren't working out as I expected: class ['a] container (v:'a) = object method map (f:'a -> 'b) : 'b container = new container (f v) end;; (* class ['a] container : 'a -> object method map : ('a -> 'a) -> 'a container end *) I gather I'm either doing something wrong, or it's not possible. I suppose my question, which one is it? and if I'm doing something wrong, some guidance would be appreciated. Thanks! -Spiros E. [0]: Note that this is a minimal, contrived example of my actual problem. The actual problem came up while writing js_of_ocaml bindings. --001a11411dcaa3a3520522780f1b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hey List,

I'm trying to create a &q= uot;container" class[0] that can store a value of type 'a, and tra= nsform that value to another value of type 'b. I'm trying to do thi= s by including a "map" method in the container that applies a fun= ction to the value and returns a new instance of container with the transfo= rmed value. Despite the annotations, the types aren't working out as I = expected:

=C2=A0 class ['a] container (v:'a) =3D obje= ct
=C2=A0 =C2=A0 method map (f:'a -> 'b) : 'b container = =3D new container (f v)
=C2=A0 end;;
=C2=A0 (* class [&= #39;a] container : 'a -> object method map : ('a -> 'a) -= > 'a container end =C2=A0*)

I gather = I'm either doing something wrong, or it's not possible. I suppose m= y question, which one is it? and if I'm doing something wrong, some gui= dance would be appreciated. Thanks!

-Spiros E.

[0]: Note that this is a minimal, contrived example o= f my actual problem. The actual problem came up while writing js_of_ocaml b= indings.
--001a11411dcaa3a3520522780f1b--