On 8/16/12 10:51 PM, Patrick Walton wrote: > On 8/16/12 1:33 PM, David Rajchenbach-Teller wrote: >> fwiw, OCaml does >> >> match myfoo with >> | #bar -> (*any item of sum type bar*) >> | `bar -> (*sum constructor `bar*) >> | bar -> (*binding*) >> >> It works nicely in practice. > > But OCaml uses capitalization for sum types, like Haskell does.
Actually, not for open sum types, in which cases OCaml uses ` (backtick) instead. But this doesn't change anything to the argument > Also Niko points out that we can make a warning if you mention a variant > in a pattern that would ordinarily be part of the type, but that variant > wasn't imported. (For example: if you mention None in a pattern matching > over option types, but None wasn't imported, you'd get a warning. Of > course None gets imported by default, so this wouldn't actually occur.) Not sure how that would work out in practice. Btw, in Opa, we used to have lots of bugs caused by this kind of ambiguity (and a purely structural type system), so I believe this is worth spending some time ironing out. Cheers, David -- David Rajchenbach-Teller, PhD Performance Team, Mozilla
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
