[
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: | Owen Gunden <ogunden@s...> |
| Subject: | Re: [Caml-list] variant type |
On Tue, Jun 17, 2003 at 02:03:35PM -0400, Ye Wu wrote: > Could you please tell me why the following doesn't work? Sure. > type shape = Square of int * int * int > |Circle of float * float * float;; > let area s = > match s with > Square (_, _, d) -> d * d > |Circle (_, _, r) -> 3.14 *. r *. r;; It's because the area function is not well-typed. If the area function is operating on a Square it wants to return an int; if it's operating on a Circle it wants to return a float. It can only return one type. Owen ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners