From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 6CB02BBC1 for ; Mon, 24 Mar 2008 09:53:41 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAAcJ50fAXQIm/2dsb2JhbACmNYEI X-IronPort-AV: E=Sophos;i="4.25,545,1199660400"; d="scan'208";a="9879193" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 24 Mar 2008 09:53:41 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m2O8rVWS009740 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 24 Mar 2008 09:53:41 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhcCAAcJ50dQW+UCiGdsb2JhbACRFwEBAQ8mlGaBCA X-IronPort-AV: E=Sophos;i="4.25,545,1199660400"; d="scan'208";a="8736402" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Mar 2008 09:53:34 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JdiQp-00054r-DZ for caml-list@inria.fr; Mon, 24 Mar 2008 08:53:27 +0000 Received: from 178.56.101-84.rev.gaoland.net ([84.101.56.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Mar 2008 08:53:27 +0000 Received: from vanicat by 178.56.101-84.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Mar 2008 08:53:27 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Remi Vanicat Subject: Re: type error Date: Mon, 24 Mar 2008 09:53:16 +0100 Organization: none Message-ID: <87myoopkoz.dlv@maison.homelinux.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 178.56.101-84.rev.gaoland.net Mail-Copy-To: never User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:ZfXaPrgnExz5Hnqnsm7mbdLUb/E= Sender: news X-Miltered: at discorde with ID 47E76C0B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 foo:01 foo:01 val:01 endline:01 val:01 remi:01 int:01 int:01 writes:01 jambon:01 jambon:01 vanicat:01 vanicat:01 idiomatic:02 Martin Jambon writes: > A more idiomatic way is to declare the following type: > > type foo = < bar: int > An even more idiomatic way to do it is by using type class: class type foo = object method bar : int end;; and then you can use #foo that will be the type you wanted, Martin's example become: # class type foo = object method bar : int end;; class type foo = object method bar : int end # let print_bar (x : #foo) = print_int x # bar;; val print_bar : #foo -> unit = # let x = (object method bar = 123 method hello () = print_endline "hello" end);; val x : < bar : int; hello : unit -> unit > = # print_bar x;; 123- : unit = () -- RĂ©mi Vanicat