caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Constraint missbehaviours??
@ 2007-03-09 15:13 Till Varoquaux
  2007-03-09 16:30 ` Zheng Li
  0 siblings, 1 reply; 2+ messages in thread
From: Till Varoquaux @ 2007-03-09 15:13 UTC (permalink / raw)
  To: ocaml ml

There seems to be a bug in the way constraint are handled:
type 'a exp=[
| `Add of 'e * 'e
| `Mul of 'e * 'e
]
constraint 'a = <exp:'e;..>

type 'a exp2=[
| 'a exp
| `Sub of 'e * 'e
| `Mul of 'e * 'e
]
constraint 'a = <exp2:'e;..>;;

doesn't type correctly but seems perfectly legal to me... Am I missing
anything here?

Till


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

* Re: Constraint missbehaviours??
  2007-03-09 15:13 Constraint missbehaviours?? Till Varoquaux
@ 2007-03-09 16:30 ` Zheng Li
  0 siblings, 0 replies; 2+ messages in thread
From: Zheng Li @ 2007-03-09 16:30 UTC (permalink / raw)
  To: caml-list

"Till Varoquaux" <till.varoquaux@gmail.com> writes:
> type 'a exp2=[
> | 'a exp
> | `Sub of 'e * 'e
> | `Mul of 'e * 'e
> ]
> constraint 'a = <exp2:'e;..>;;
>
> doesn't type correctly but seems perfectly legal to me... Am I missing
> anything here?

Don't understand the purpose why you programming this way. But if what you want
the type check to recognize the `Mul 'e * 'e here has the same 'e as the 'e
inside 'a exp, you should explicit it, I don't see reasons why type checker
will unify these two polymorphic type parameters.

# type 'a exp2 = [
| (<exp:'e; ..> as 'a) exp
| `Sub of 'e * 'e
| `Mul of 'e * 'e
] constraint 'a = <exp2:'e; ..>;;
type 'a exp2 = [ `Add of 'b * 'b | `Mul of 'b * 'b | `Sub of 'b * 'b ]
constraint 'a = < exp : 'b; exp2 : 'b; .. >



-- 
Zheng Li
http://www.pps.jussieu.fr/~li


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

end of thread, other threads:[~2007-03-09 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-09 15:13 Constraint missbehaviours?? Till Varoquaux
2007-03-09 16:30 ` Zheng Li

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