Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Cygwin ocaml crashes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Hecker <checker@d...>
Subject: Re: [Caml-list] Subtypes in Ocaml

>Patternmatching seems to do it. if this isn't the right way to do it,
>please, someone let me know before i do something stupid.

I'm not 100% sure what you're saying.  My first interpretation of your question leads me to say "this is what variants and pattern matching are all about".  Since a variant is a union type, it can be a Literal and just an expression and pattern matching will let you choose which to interpret it as.

My second interpretation is that you want to have a function typed to only take a subset of the variant type.  In this case, you can either use exceptions (the default pattern match one, or one raised with a | _ -> failwith "bad type" if you don't want the compiler warnings), or I think you can do something with polymorphic variants, but I must admit to being kind of confused by them.

Chris

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr