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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E6E2BBC69 for ; Tue, 31 Jul 2007 01:03:04 +0200 (CEST) Received: from bsd4.nyct.net (mail-out8.nyct.net [216.139.141.8]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6UN31nm019500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 31 Jul 2007 01:03:04 +0200 Received: from [192.168.42.2] (adsl-216-139-154-52.nyct.net [216.139.154.52]) by bsd4.nyct.net (8.13.4/8.13.4) with ESMTP id l6UN2xH5020170 for ; Mon, 30 Jul 2007 19:03:00 -0400 (EDT) (envelope-from bhurt@spnz.org) Date: Mon, 30 Jul 2007 19:13:21 -0400 (EDT) From: Brian Hurt X-X-Sender: bhurt@localhost To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Void type? In-Reply-To: <1185770437.11618.29.camel@rosella.wigram> Message-ID: References: <46AC748B.10200@lix.polytechnique.fr> <200707291216.34682.jon@ffconsultancy.com> <46AC7BB8.8050609@gmail.com> <20070729124340.GA18564@furbychan.cocan.org> <46AC8EEF.1040102@gmail.com> <20070729170216.GA8137@furbychan.cocan.org> <46ACF35F.5070102@lix.polytechnique.fr> <1185770437.11618.29.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 46AE6E25.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; sig:01 struct:01 foo:01 a's:01 refactor:01 refactor:01 struct:01 a's:01 nail:98 req:98 req:98 blythe:98 caml-list:01 module:03 module:03 Just to nail this thread shut, I have been convinced of the utility of a void type (as distinct from the unit type) in pragmatic code. Consider the following module signature: module type Req = sig type a type b end;; module Example(Base: Req) = struct type a_or_b = | A of Base.a | B of Base.b ;; let foo (x: a_or_b list) = ... end;; An important point to notice here is that the Example module signature can not be factored into a "a part" and a "b part" without losing important capabilities- for example, being able to pass in a list that contains both a's and b's. Even assuming you have full control of the source code and time and inclination (if needed) to refactor the code, a refactoring is still not possible. So my blythe "just refactor the module" doesn't apply. So how do I use that module and say, in the type system, "I will never pass in a b"? This is where the void type comes in. I can declare: module Myreq = struct type a = whatever;; type b = void;; end;; module Myexample = Example(Myreq);; Note that I can still call function Myexample.foo- I can call it with an empty list, or with a list of as many A's as I want. But it's impossible for me to create a B element. Brian