From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA16465; Thu, 11 Oct 2001 09:11:12 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA16742 for ; Thu, 11 Oct 2001 09:11:11 +0200 (MET DST) Received: from bassia.wanadoo.fr (smtp-rt-5.wanadoo.fr [193.252.19.159]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f9B7BAn19568 for ; Thu, 11 Oct 2001 09:11:10 +0200 (MET DST) Received: from amyris.wanadoo.fr (193.252.19.150) by bassia.wanadoo.fr; 11 Oct 2001 09:11:09 +0200 Received: from debian (217.109.144.240) by amyris.wanadoo.fr; 11 Oct 2001 09:10:50 +0200 Received: from moi by debian with local (Exim 3.32 #1 (Debian)) id 15ra05-0000Zq-00 for ; Thu, 11 Oct 2001 09:11:25 +0200 To: caml-list@inria.fr Subject: Re: [Caml-list] Newbie question concerning type definitions References: <3BC55BCA.15676.5F0873@localhost> From: Remi VANICAT Date: 11 Oct 2001 09:11:25 +0200 In-Reply-To: <3BC55BCA.15676.5F0873@localhost> Message-ID: <87g08qejmq.dlv@wanadoo.fr> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.105 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "Thomas Link" writes: > Hello, > > I have hesitated to send this question to this mailing list as I > suspect it to be rather stupid. What am I trying to do? I would like to > implement a simple stack based language in OCaml in order to get a > feeling for OCaml and also to test some ideas. Well, I didn't get far > as I wasn't even able to define the basic data structures. I guess this > is plain wrong: > > type returnState = Succeeded | Failed | Error of int > and proc = (stack -> dictionary -> returnState) > and procs = proc list > and element = > Int of int > | String of string > | Float of float > | Word of proc > and stack = element Stack.t > and dictionary = (string, procs) Hashtbl.t;; > > When compiling this, the compiler tells me that proc's definition is > cyclic. How can I circumvent this in OCaml? this is a FAQ (is this FAQ in the FAQ ?) There is two possible answer : First add the -rectype option to the compiler to allow such recursive type, Secondly, put the proc type into a constructor : type returnState = Succeeded | Failed | Error of int and proc = Proc of (stack -> dictionary -> returnState) and procs = proc list and element = Int of int | String of string | Float of float | Word of proc and stack = element Stack.t and dictionary = (string, procs) Hashtbl.t;; -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr