From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA09219; Wed, 25 Apr 2001 09:42:24 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA08438 for ; Wed, 25 Apr 2001 09:42:23 +0200 (MET DST) Received: from staff.cs.usyd.edu.au (staff.cs.usyd.edu.au [129.78.8.1]) by concorde.inria.fr (8.11.1/8.10.0) with SMTP id f3P7gJX06441 for ; Wed, 25 Apr 2001 09:42:20 +0200 (MET DST) Received: from hons.cs.usyd.edu.au. by staff.cs.usyd.edu.au.; Wed, 25 Apr 2001 17:42:15 +1000 Received: from localhost (mrak@localhost) by hons.cs.usyd.edu.au (8.9.3/8.9.3) with ESMTP id RAA25971 for ; Wed, 25 Apr 2001 17:42:14 +1000 X-Authentication-Warning: hons.cs.usyd.edu.au: mrak owned process doing -bs Date: Wed, 25 Apr 2001 17:42:14 +1000 (EST) From: Mark Wotton hons2001 To: caml-list@inria.fr Subject: Re: [Caml-list] Subtypes in Ocaml In-Reply-To: <4.3.2.7.2.20010425002928.00d588b0@shell16.ba.best.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 25 Apr 2001, Chris Hecker wrote: > > >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. Yes, that was it. I had a suspicion it was a dumb question... i'm just not used to using pattern-matching like that. It's working nicely now. > 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), Yes, I want this too. Pattern matching seems to do it nicely. I was doing without it and wondering why everything was so hard... > or I think you can do something with polymorphic variants, but I must > admit to being kind of confused by them. I might wait until i'm a hardcore ocaml hacker, then. Might be a while. mrak ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr