[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Martin Jambon <m.jambon@i...> |
| Subject: | Re: [Caml-list] Type aliases |
> You can get something close to what you want with: > > module Ints : > sig > type 'a integer > > val int: int -> 'a integer > val get: 'a integer -> int > > val ( + ): 'a integer -> 'a integer -> 'a integer > val ( * ): 'a integer -> 'a integer -> 'a integer > (* etc... *) > end = > struct > type 'a integer = int > let int x = x > let get x = x > include Pervasives > end Great! Thanks a lot. Finally, I decided to define only the 2 conversion functions, since we have to make difficult choices like the following: Should we define val ( * ) : 'a integer -> 'b integer -> 'b integer or val ( * ) : 'a integer -> 'a integer -> 'a integer or val ( * ) : int -> 'a integer -> 'a integer ? So, this is enough to avoid confusion between keys that have the same representation (commonly int or string) and is complementary to the use of labeled arguments. (and no preprocessing is required to make (1 + 1) valid). Martin ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners