caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <m.jambon@ibcp.fr>
To: Alain Frisch <frisch@clipper.ens.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Type aliases
Date: Fri, 29 Nov 2002 15:03:26 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.40.0211291436250.1394-100000@pc-bioinfo1.ibcp.fr> (raw)
In-Reply-To: <Pine.SOL.4.44.0211281945550.16772-100000@clipper.ens.fr>

> 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


  reply	other threads:[~2002-11-29 14:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-28 18:01 Martin Jambon
2002-11-28 18:51 ` Alain Frisch
2002-11-29 14:03   ` Martin Jambon [this message]
2002-11-28 18:55 ` Alessandro Baretta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.40.0211291436250.1394-100000@pc-bioinfo1.ibcp.fr \
    --to=m.jambon@ibcp.fr \
    --cc=caml-list@inria.fr \
    --cc=frisch@clipper.ens.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).