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.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 51459BC69 for ; Wed, 24 Oct 2007 20:16:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEYoH0dA6bjinmdsb2JhbACOWgIBAQcEBhEYgSc X-IronPort-AV: E=Sophos;i="4.21,325,1188770400"; d="scan'208";a="18570087" Received: from wr-out-0506.google.com ([64.233.184.226]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Oct 2007 20:16:22 +0200 Received: by wr-out-0506.google.com with SMTP id c8so233427wra for ; Wed, 24 Oct 2007 11:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=Ulyk0fx9nam037hxy6sQQMkF92rkk6ldMcyD2RToDh4=; b=ck5DEynTP4+o2QrrzJAicC1gj6NWY1ywmIkRPHMAmFSIx/NA7XzexH8J0bILT1lhNKa9ISeKXTSUviitnmo9VMD/G11nzDMLsekL8qKTSFaYaDbAPdLDPEWzpsxVLkv245R9mr3QyITHtyHToW6kjwUWkObA9d+fXE6slNzBBes= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=g6nSi5XFTfCkECbTObTYRlpPGGAS3uqSp6GHlQFIswmK3XvNQqbYQjQnRA/nUMLVtA2n5O5cj5pFjat/qeRMMN+01PEnXvmLjcMUIJS4W4q5hKxkYQGQ+9ojcYMam9ALD34qknAVkI/aBsXnA9MlJxAaqw/ZMJ9+jHkLY9/D+dw= Received: by 10.142.157.15 with SMTP id f15mr301167wfe.1193249353342; Wed, 24 Oct 2007 11:09:13 -0700 (PDT) Received: by 10.143.168.5 with HTTP; Wed, 24 Oct 2007 11:09:13 -0700 (PDT) Message-ID: <9d3ec8300710241109ie0d1350v7f0201e635defc4d@mail.gmail.com> Date: Wed, 24 Oct 2007 14:09:13 -0400 From: "Till Varoquaux" To: "Brian Hurt" Subject: Re: [Caml-list] type abbreviation is cyclic Cc: "William W Smith" , caml-list@yquem.inria.fr In-Reply-To: <471F847C.1050609@janestcapital.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <344522.90449.qm@web82102.mail.mud.yahoo.com> <471F847C.1050609@janestcapital.com> X-Spam: no; 0.00; abbreviation:01 -rectypes:01 ocaml:01 recursion:01 recursive:01 afaik:01 -rectypes:01 inference:01 abbreviation:01 inserting:01 emptylist:01 beginner's:01 ocaml:01 bug:01 polymorphic:01 Yes, This used to be a FAQ entry: unless you pass the -rectypes option to ocaml you have to pass through a constructor (record variant...) to break your recursion, this prevents writing empty types such as: type pb = pb * pb You can still write infinite recursive definitions : type a = Succ of a;; let rec infinity = Succ infinity;; AFAIK -rectypes doesn't break any of the programs working before but if you attend to use it you will probably run in problems with type inference (not polymorphic enough). I would recommend steering clear of it for anything else than toy programs. Till On 10/24/07, Brian Hurt wrote: > William W Smith wrote: > > > I wonder whether this error is an example of the language being > > defined more restrictively than required. What is the reason that I > > get these results? > > > > type a = int -> one -> int and one = Unused | One of a;; > > type b = int -> b -> int > > > > type a is accepted while type b is not. (b gives "The type > > abbreviation b is cyclic" However, in the uses that I intended, there > > won't be any actual difference between the two. > > > > I'd appreciate an explanation about why there is difference between a > > and b. > > > I *think* this has to do with being able to bottom out data structures. > I mean, consider the following two (similiar) types: > > type a = int * one * int and one = Unused | One of a;; > type b = int * b * int;; > > How do you specify a limited-length member of type b? You can with a > just by inserting Unused in the correct location. But there's no such > "stopping point" for b. > > This makes more sense when you make the linked-list aspect more plain: > > type a = int * next and next = EmptyList | Cons of a;; > type b = int * b;; > > Hopefully someone more knowledgeable than I will post an actual > type-theoretical reason this is so, but this is the pragmatic reason > I've found. > > Brian > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://till-varoquaux.blogspot.com/