Version française
Home     About     Download     Resources     Contact us    
Browse thread
Symbol type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: bluestorm <bluestorm.dylc@g...>
Subject: Re: [Caml-list] Symbol type
If your set of symbol is closed, you can use a variant type (sum type).

type symbols =
| A
| B


If you really need open symbols, you can use [polymorphic variants].

Let tag_a foo = (`A, foo)

 [polymorphic variants]
http://caml.inria.fr/pub/docs/manual-ocaml/manual006.html#toc36


However, you won't have convenience functions such as string_of_symbol; you
would have to define them yourself.