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 HAA07996; Mon, 3 Sep 2001 07:46:31 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA07928 for ; Mon, 3 Sep 2001 07:46:30 +0200 (MET DST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f835kT129538 for ; Mon, 3 Sep 2001 07:46:30 +0200 (MET DST) Received: from localhost (patrick@localhost) by fledge.watson.org (8.11.6/8.11.5) with SMTP id f835kCi37983; Mon, 3 Sep 2001 01:46:13 -0400 (EDT) (envelope-from patrick@watson.org) Date: Mon, 3 Sep 2001 01:46:12 -0400 (EDT) From: Patrick M Doane To: Michael Leary cc: caml Subject: Re: [Caml-list] function type confusion (using let) In-Reply-To: <20010902222555.A22545@ip178.usw22.rb1.bel.nwlink.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2 Sep 2001, Michael Leary wrote: > I was trying to be clever about not using ;; and minimizing my use of ; in > files, and I've gone off the deep end... Nothing to do with the use of ; here... > Why is this wrong, and how do I fix it?: Build up expressions slowly until you have a good understanding of how the typechecker works. The conditional statement if e1 then e2 has type unit and requires e1 to have type bool and e2 to have type unit The conditional expression if e1 then e2 else e3 has type 'a where the types of e2 and e3 are both 'a. Similarly e1 has type bool. In your code, the last if clause is missing an else branch so there is a type error. What do you want the result to be if x is not > 0.0 and not < 0.0? > let pi = 3.14159 > let pi2 = 2.0 *. pi > > let normr r = > let x = mod_float r pi2 in > if x > 0.0 then > if x > pi then > -.pi2 +. x > else > x > else if x < 0.0 then > if x < -.pi then (* <------ here *) > pi2 +. x > else > x ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr