<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Translating Fortran mixed mode arithmetic<br>expressions into Haskell is quite a challenge.<br>Believe it or not<br><br>c=10.**(11-int(alog10(r)+10))<br><br>translates to<br><br>let c = (**) 10.0 $ fromIntegral $ subtract 11 $ truncate $ (+) (logBase 10.0 r) 10.0<br><br>I finally broke the expression below into two parts<br>(k1 & k2) to ease translation. I get it that Haskell is<br>expecting to subtract two Integers and is instead<br>being given an Integer and a Double. What must<br>I do to make this work? Are there any guidelines<br>for doing this kind of translation work?<br><br>Michael <br><br>================<br><br>Prelude> let mm = 2<br>Prelude> let k1 = 3*mm+2<br>Prelude> let k2 = (/) 150 119<br>Prelude> let k = k1 - k2<br><br><interactive>:1:13:<br> Couldn't match expected type
`Integer'<br> against inferred type `Double'<br> In the second argument of `(-)', namely `k2'<br> In the expression: k1 - k2<br> In the definition of `k': k = k1 - k2<br>Prelude> :t 150/119<br>150/119 :: (Fractional t) => t<br>Prelude> <br><br></td></tr></table><br>