Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] dynamic runtime cast in Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-12 (09:09)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] dynamic runtime cast in Ocaml
From: Alain Frisch <>
> > By the way, for the expressivity addict (Curry-style), there is now a
> > multimatch branch in CVS with support for a specific form of
> > dependent types. 
> Nice !  Do you have specific cases of application in mind ?
> It's amazing to see how Caml succeed in escaping ML jail (rows, HO
> polymorphism, etc...).

I don't know. Actually I was quite dubious about the usefulness of
such a feature until a member of the Coq team told me that he
sometimes wished he could write programs that way. I suppose you need
some exposure to higher-order type systems before you can imagine
By the way, there was a nice example of encoding set types in variants
in TIP'02 in Dagstuhl, and this encoding would work (partially) with
this extension.

> Any long-term plan for inclusion in OCaml ?

None. This feature is fun, but it's still unclear whether it is really
useful. Not that i'm not convinced that dependent types are useful,
but dependent types are much more than this simple hack.

Another problem is that while type inference works nicely,
interface inclusion is hard to check (Francois Pottier told me it was
NP-complete). I'm still looking for a reasonable algorithm:
exponential in the number of constructors is a bit too much.

> I guess that backtracking unification could benefit to OCaml in other
> places (e.g.:undoing the effect of typing an ill-typed expression in the
> toplevel).

Always looking in the corners, you are.
This is unrelated to the rest of the patch, and I actually plan to move
backtracking to the main trunk in the future.

> Do you have any paper/doc describing multimatch typing ?

All the theory (and why it was so easy) is in my FOOL9 paper.

For the implementation, it's just two new keywords, multifun and
multimatch, that trigger different typing rules.  Also there is clever
typing for as-patterns, which can help you get more readable types:

# let f x = multimatch x with `A -> 1
            | `B -> multimatch x with `A -> 'a' | `B -> true;;
val f : [< `A & 'a = int & 'b = char | `B & 'a = 'b & 'b = bool] -> 'a
# let f' = multifun `A|`B as x -> f x;;
val f' : [< `A & 'a = int | `B & 'a = bool] -> 'a

Jacques Garrigue      Kyoto University     garrigue at
		<A HREF=>JG</A>
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: