caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Polymorphic variant as a witness?
@ 2008-06-21 23:11 David Teller
  2008-06-21 23:27 ` [Caml-list] " Christophe TROESTLER
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: David Teller @ 2008-06-21 23:11 UTC (permalink / raw)
  To: OCaml

      Dear list,

 I have been thinking for some time about using polymorphic variants to
encode some aspects of a types-and-effects type system in OCaml using
Camlp4. While the idea is still quite fuzzy, I have the feeling that, if
I could have a value (let's call it "witness") with type 
  [> ] ref
which I could "touch" into becoming 
  [> `A] ref
then
 [> `A | `B] ref
etc. as effects `A, `B, etc. appear in the program, it could provide
interesting information on the effects of the program. 

 Now, of course, I can't define a value with type ref [> ] or even with
type ref [> `dummy]. That is, when compiling a module consisting only in
a declaration such as
   let witness = ref `dummy
I'm faced with the good old "cannot be generalised" error message. This
strikes me as normal -- I'm sure that, with the right modifications on
witness, I could cause runtime type inconsistencies for any client
attempting to read the value of witness. However, in this case, I'm not
going to read any value from witness, ever. I only want to "touch" it
into becoming something a tad more complex, which I could then look at
with ocamlc -i or such.

My question is: is there a way to hijack polymorphic variants into doing
what I wish? Or to encode this behaviour somehow?

Thanks,
 David

-- 
David Teller
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings liquidations. 


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

end of thread, other threads:[~2008-07-04 13:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-21 23:11 Polymorphic variant as a witness? David Teller
2008-06-21 23:27 ` [Caml-list] " Christophe TROESTLER
2008-06-21 23:52   ` David Teller
2008-06-23  8:13 ` Romain Bardou
2008-06-23 10:27 ` Jacques Garrigue
2008-06-27  6:00   ` David Teller
2008-06-27  6:38     ` Jacques Garrigue
2008-07-04 13:05 ` Polymorphic variant + phantom type as a witness Gleb Alexeyev

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