<div>Hello,</div>
<div> </div>
<div>I'm new to Haskell and it seems like a very nice language to learn. However I'm not really familiar with the errormessages it produces. I am using a Helium interpreter. I've created the following module (however it is just a small sketch). I've written the following code:</div>
<div> </div>
<div>fac :: Int -> Int<br>fac n = product[1..n]</div>
<div> </div>
<div>boven :: Int -> Int -> Int<br>boven n k = (fac n) `div` fac k * fac (n-k)</div>
<div> </div>
<div>bin :: Int -> Int -> Int -> Int<br>bin n k p |(n-k)>0 && k>0 = (boven n k) * (p^k) * (1-p)^(n-k)<br> |(n-k)<0 && k>0 = (boven n k) * (p^k) * (1/((1-p)^(-(n-k))))<br>
|(n-k)<0 && k<0 = (boven n k) * (1/(p^(-k))) * (1/((1-p)^(-(n-k))))</div>
<div> </div>
<div>When I load this into my interpreter it says:</div>
<div> </div>
<div>Compiling ./Test.hs<br>(11,55): Type error in infix application<br> expression : 1 / ((1 - p) ^ (-(n - k)))<br> operator : /<br> type : Float -> Float -> Float<br> does not match : Int -> Int -> Int </div>
<div>(12,47): Type error in infix application<br> expression : 1 / (p ^ (-k))<br> operator : /<br> type : Float -> Float -> Float<br> does not match : Int -> Int -> a </div>
<div>(12,62): Type error in infix application<br> expression : 1 / ((1 - p) ^ (-(n - k)))<br> operator : /<br> type : Float -> Float -> Float<br> does not match : Int -> Int -> a </div>
<div>Compilation failed with 3 errors</div>
<div> </div>
<div>Some details that might be usefull:</div>
<div> </div>
<div>Line 11 is |(n-k)<0 && k>0 = (boven n k) * (p^k) * (1/((1-p)^(-(n-k))))</div>
<div>Line 12 is |(n-k)<0 && k<0 = (boven n k) * (1/(p^(-k))) * (1/((1-p)^(-(n-k))))</div>
<div> </div>
<div>So my question is: how can I fix these errors?</div>
<div> </div>
<div>(I used these lines of codes because it is not possible to use a negative exponent in the Helium interpreter.)</div>
<div> </div>
<div>Thank you for answering my question!</div>
<div> </div>
<div>Greetings JTKM</div>