<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">My query was in response to an earlier post claiming that ai was a Rational, which post he almost simultaneously said to ignore.<br><br>I've used GHC and like it better than Hugs, but the Fedora Linux package is humongous and I'm only on dialup right now.<br><br>I'm still not sure what some of the error messages I was getting were about. As I wrote the function I tried to be aware of what "mixed mode" operations were kosher ala<br><br>Main&gt; 1 / (6%7)<br>7 % 6<br>Main&gt; 1 - (6%7)<br>1 % 7<br>Main&gt; (6%7) - 1<br>(-1) % 7<br>Main&gt; <br><br>but still kept getting kicked out.<br><br>Better error messages certainly couldn't hurt.<br><br>Thanks.<br><br>Michael<br><br><br>--- On <b>Mon, 3/30/09, Ketil Malde <i>&lt;ketil@malde.org&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From:
 Ketil Malde &lt;ketil@malde.org&gt;<br>Subject: Re: [Haskell-cafe] Rational and % operator remix<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: "Brandon S. Allbery KF8NH" &lt;allbery@ece.cmu.edu&gt;, haskell-cafe@haskell.org<br>Date: Monday, March 30, 2009, 2:48 AM<br><br><div class="plainMail">michael rice &lt;<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt; writes:<br><br>&gt; cf2 :: Rational -&gt; [Int]<br>&gt; cf2 a = let ai = floor a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-- Doesn't this make ai an Int? &nbsp; -Michael<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if a == (toRational ai)<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then [ai]<br>&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else ai : cf2 (1 / (a - ai))<br><br>One thing that you could try, is ghci in addition to (or instead of)<br>Hugs.&nbsp; That will give you another take on the error messages, where<br>Hugs says:<br><br>&gt; Main&gt; :load cf.hs<br>&gt; ERROR "cf.hs":7 - Type error in application<br>&gt; *** Expression&nbsp;&nbsp;&nbsp;&nbsp; : ai : cf2 (1 / (a - ai))<br>&gt; *** Term&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ai<br>&gt; *** Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Ratio Integer<br>&gt; *** Does not match : Int<br><br>ghci will tell you:<br><br>&nbsp; &nbsp; Couldn't match expected type `Rational' against inferred type `Int'<br>&nbsp; &nbsp; In the second argument of `(-)', namely `ai'<br>&nbsp; &nbsp; In the second argument of `(/)', namely `(a - ai)'<br>&nbsp; &nbsp; In the first argument of `cf2', namely `(1 / (a -
 ai))'<br><br>So while this is (almost) right:<br><br>&gt; cf2 a = let ai = floor a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-- Doesn't this make ai an Int? &nbsp; -Michael<br><br>The problem is the subtraction of ai from a, which forces them to be<br>the same type.&nbsp; I tend to find ghc's messages more informative than<br>Hugs's (but perhaps it is just that I am more familiar with ghc?).<br><br>-k<br>-- <br>If I haven't seen further, it is by standing in the footprints of giants<br></div></blockquote></td></tr></table><br>