Browse thread
[Caml-list] variant with tuple arg in pattern match?
- Chris Hecker
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Chris Hecker <checker@d...> |
| Subject: | [Caml-list] variant with tuple arg in pattern match? |
I can't find anything about this in the docs, faq, or list archives. I expected ii to be bound to the int * int tuple (1,2) in this pattern match: # type foo = Foo of int * int;; type foo = Foo of int * int # match Foo (1,2) with Foo ii -> ii ;; Characters 23-29: The constructor Foo expects 2 argument(s), but is here applied to 1 argument(s) This works: # match Foo (1,2) with Foo _ -> () ;; - : unit = () But I can't get an "as" clause to work, either: # match Foo (1,2) with Foo ((_,_) as ii) -> ii ;; Characters 21-38: The constructor Foo expects 2 argument(s), but is here applied to 1 argument(s) But, even if the "as" worked, it's messy compared to the top method. Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr