English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Newbie question concerning type definitions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-11 (06:44)
From: Thomas Link <t.link.tmp200101@g...>
Subject: [Caml-list] Newbie question concerning type definitions

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? 

My apologies if this is too simple-minded for being asked in this 
forum, but could somebody tell me please how the correct definition of 
these types could possibly look like? 

Cheers, Thomas. 

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