Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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]

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