From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 97EA4BB91 for ; Fri, 28 Jan 2005 15:47:01 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0SEl00W020068 for ; Fri, 28 Jan 2005 15:47:00 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA06925 for ; Fri, 28 Jan 2005 15:47:00 +0100 (MET) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0SEkxla020065 for ; Fri, 28 Jan 2005 15:47:00 +0100 Received: from zonule.cl.cam.ac.uk ([128.232.9.23] helo=cl.cam.ac.uk ident=[x7G6gFMbC0QBGc1H3+MpVlCExGEvPjjQ]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1CuXOh-00051X-00; Fri, 28 Jan 2005 14:46:55 +0000 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: Stefan Monnier Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: '_a In-reply-to: Your message of "Fri, 28 Jan 2005 08:25:10 EST." <87llad3czw.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Date: Fri, 28 Jan 2005 14:46:55 +0000 From: Keith Wansbrough Message-Id: X-Miltered: at concorde with ID 41FA5064.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41FA5063.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 umontreal:01 ocaml:01 ...:98 ...:98 exception:01 exception:01 writes:01 typing:01 raise:03 explicit:03 implicit:03 problem:05 indeed:05 attempted:08 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Stefan Monnier writes: > > (b) the codomain is mis-specified, we actually have > > List.hd: 'a list -> Some 'a > > Funny, I always assumed that the domain of List.hd was "'a list - []". Yes, indeed. Were List.hd of type 'a list -> 'a option, we'd be stuck if we ever wanted actually to _use_ the value: any function that attempted to extract it (say f : 'a option -> 'a) would have to have a similar type (f : 'a option -> 'a option). The same problem would ensue if we had explicit exception typing: List.hd : 'a list -> 'a with_possible_exception extract : 'a with_possible_exception -> 'a option really_extract : 'a option -> 'a with_possible_exception and so on...! The only way out of this mess is to add a monad. OCaml already has one: return is implicit, bind is called ";", and the monad operations include "raise" and "try ... with ...". HTH. --KW 8-)