caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocaml type with constraints?
@ 2008-09-21 22:01 Angela Zhu
  2008-09-21 22:05 ` [Caml-list] " Andrej Bauer
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Angela Zhu @ 2008-09-21 22:01 UTC (permalink / raw)
  To: caml-list

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

Hi,
I want to define an OCaml type with constraints.
For example:

type item = Item of int * float;;

If here this float type is for price of some item, and I want to make sure
it is positive. In other words, if x = (xi, xf) of type item,
I want to enforce, xf must >= 0.

Is there a way to define OCaml type like this?

Thanks a lot!
Angela

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

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

end of thread, other threads:[~2008-09-21 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-21 22:01 Ocaml type with constraints? Angela Zhu
2008-09-21 22:05 ` [Caml-list] " Andrej Bauer
2008-09-21 23:10   ` Martin Jambon
2008-09-21 22:50 ` Gordon Henriksen
2008-09-21 23:55 ` Jacques Garrigue

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