caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Attach an invariant to a type
@ 2008-01-31 13:28 Dawid Toton
  2008-01-31 13:50 ` [Caml-list] " Romain Bardou
  0 siblings, 1 reply; 11+ messages in thread
From: Dawid Toton @ 2008-01-31 13:28 UTC (permalink / raw)
  To: caml-list

What should I do if I have need for the following? Does already exist 
any equivalent solution?

I'd like to write:

type subindex = int invariant x -> (x>=10)&&(x<=100)

let doit (a:subindex) (b:subindex) =
  let result = some_operation a b in
  (result:subindex)

And it should be translated to:

type subindex = int
let subindex_invariant x = (x>=10)&&(x<=100)

let doit (a:subindex) (b:subindex) =
  assert (subindex_invariant a);
  assert (subindex_invariant b);
  let result = some_operation a b in
  assert (subindex_invariant result);
  (result:subindex)

Am I going right direction at all?

----------------------------------------------------
Promocyjne oferty biletów lotniczych!
Praga, Rzym, Paryż, Mediolan już od 499zł - Kliknij:
http://klik.wp.pl/?adr=http%3A%2F%2Fsamoloty.wp.pl%2Fpromocje%2F&sid=202


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

end of thread, other threads:[~2008-02-10 18:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-31 13:28 Attach an invariant to a type Dawid Toton
2008-01-31 13:50 ` [Caml-list] " Romain Bardou
2008-01-31 17:58   ` David Teller
2008-01-31 18:13     ` Romain Bardou
2008-01-31 19:13       ` Hezekiah M. Carty
2008-01-31 19:29         ` Stéphane Lescuyer
2008-01-31 19:51           ` Dawid Toton
2008-01-31 20:26             ` Edgar Friendly
2008-02-01 10:00               ` Keiko Nakata
2008-01-31 20:13           ` Romain Bardou
2008-02-10 18:00           ` Stéphane Glondu

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