caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* define incompatible type
@ 2010-02-12  6:32 Grégoire Seux
  2010-02-12  7:33 ` [Caml-list] " David Rajchenbach-Teller
  0 siblings, 1 reply; 6+ messages in thread
From: Grégoire Seux @ 2010-02-12  6:32 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

hello !

i would like to create two types and use the type checker to verify the
"meaning" of my programs:

type user_id = int

type movie_id = int


i'd like if the type checker would warn me if i write something that is
non-sense:

> let a:user_id = 57 and b:movie_id = 80 in

if a=b then ...


because this is obvioulsy a mistake

do you know if is this possible ?
thanks by advance !


-- 
Grégoire

[-- Attachment #2: Type: text/html, Size: 1477 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Caml-list] define incompatible type
@ 2010-02-12  9:25 abau
  0 siblings, 0 replies; 6+ messages in thread
From: abau @ 2010-02-12  9:25 UTC (permalink / raw)
  To: caml-list

On Fri, 12 Feb 2010 13:13:33 +0530
Grégoire Seux <kamaradclimber@gmail.com> wrote:

> too bad it does not exist !

>From ocaml language definition:

> The optional type equation "= typexpr" makes the defined type
> equivalent to the type expression "typexpr" on the right of the "="
> sign: one can be substituted for the other during typing.

When "type foo = int" then foo is just a type alias for int and
therefor it can/will be substituted by int.

_____________________________________________
HTWK Leipzig FbIMN Webmail, https://webmail.imn.htwk-leipzig.de




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-12 20:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-12  6:32 define incompatible type Grégoire Seux
2010-02-12  7:33 ` [Caml-list] " David Rajchenbach-Teller
2010-02-12  7:43   ` Grégoire Seux
2010-02-12 10:59   ` David Allsopp
2010-02-12 20:26     ` Guillaume Yziquel
2010-02-12  9:25 abau

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).