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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id F1E79BC69 for ; Wed, 14 Nov 2007 17:09:45 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKasOkfRVYT6mGdsb2JhbACPAgIBAQcCBhMY X-IronPort-AV: E=Sophos;i="4.21,417,1188770400"; d="scan'208";a="19291103" Received: from an-out-0708.google.com ([209.85.132.250]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Nov 2007 17:09:45 +0100 Received: by an-out-0708.google.com with SMTP id c24so49865ana for ; Wed, 14 Nov 2007 08:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=czuoJzHc84wmnoOE+PteS/nxXCgSf+dM0u9WQwqSdpg=; b=CPm6jyau2v7SD2UEGSYMqEOu2BFfeMpaQl48Yy9GqwgHQ6E4osBo6arLf9MIEPX6r+SPxk/6fs2lStqT/3nyYNUB+GAVbzypKM2yMgT9JiRbue4pjTWVfWEwwIeoO51aeKtLp6Ral3uhOSUoLHcm+iavrBr/SJjYHKrregDYEXI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=KIuYFGrYB2MeESyHiD4ZnDNfDicrEpRcTPoQeFb8yZVS4g0AVd1r7nP5ZUe1nyVnFMCJGVQ6Oc44QbQAfvmBMtRAfOXFztYYp+Loy/giN5q+NmEzXg4s/D1rT+AcpXSxiJllhfftSfuOaaJsZfr34J7qIyLBBnQn+Y7krzjvlEs= Received: by 10.100.201.16 with SMTP id y16mr6277236anf.1195056584367; Wed, 14 Nov 2007 08:09:44 -0800 (PST) Received: from ?192.168.0.7? ( [69.152.94.247]) by mx.google.com with ESMTPS id c29sm1001250anc.2007.11.14.08.09.42 (version=SSLv3 cipher=RC4-MD5); Wed, 14 Nov 2007 08:09:42 -0800 (PST) Message-ID: <473B1DC4.8030307@gmail.com> Date: Wed, 14 Nov 2007 10:09:40 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Yaron Minsky Cc: caml-list Subject: Re: [Caml-list] Compiler feature - useful or not? References: <473A363F.2080301@gmail.com> <891bd3390711131608g48b584a4n6b0ccab95d7de3f3@mail.gmail.com> In-Reply-To: <891bd3390711131608g48b584a4n6b0ccab95d7de3f3@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; compiler:01 yaron:01 minsky:01 sig:01 val:01 val:01 implements:01 compiler:01 syntax:01 ocamlc:01 edgar:98 wrote:01 faq:01 rewrite:01 readable:01 Yaron Minsky wrote: > module type Abs_int : sig > type t > val to_int : t -> int > val of_int : int <- t > end > > And then you write concrete module Int that implements this signature. You > can then write: > > module Row : Abs_int = Int > module Col : Abs_int = Int > This approximates my idea of "optimal" well enough that I'll rewrite some of my old code to use it. It loses some opportunities for compiler optimization, but otherwise seems perfect. No repetitive boilerplate to write over and over, no unnecessary boxing, efficient conversion to the base type (well, it still requires a function call to find out that nothing needs to change, and maybe there's a shallow copy created in this process), easy on the eyes/fingers syntax for conversion and declaration and a readable type name for ocamlc to report when things go wrong. Thanks for sharing this gem. Any chance it can be added to a/the FAQ? E.