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
[Caml-list] Type aliases
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <m.jambon@i...>
Subject: [Caml-list] Type aliases

I would like to have the following properties:

1) Define type aliases:

     type year = int
     and month = int

2) Don't hide their representation and derive the primitives from the
   original type:

     # let next_year = current_year + 1 ;;
     val next_year : year = 2003

   (+) and 1 would be silently converted to types using year instead of

3) Prohibit the mixing of different types that do not derive from each
   other, without an explicit cast:

     let my_mistake = year + month   (* Type error! *)

   where year has type year and month has type month.
   But this could be valid:

     let some_int = (year :> int) * 13 + month

Basically, I would like to minimize the risk of error when I manipulate
simple datatypes like numerical parameters or int/string identifiers.

Thanks for any suggestion!


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: