[Haskell-cafe] Unresolved overloading error
Scott Brown
doolagarl2002 at yahoo.com.au
Sat Mar 31 05:04:30 EDT 2007
I have written this code in Haskell which gives an unresolved overloading error.
The function bernoulli should give the probability of j successes occuring in n trials, if each trial has a probability of p.
> fac 0 = 1
> fac n = n * fac(n - 1)
> binom n j = (fac n)/((fac j)*(fac (n - j)))
> bernoulli n p j = (binom n j)*(p ^ j) * ((1 - p)^(n - j))
However, bernoulli 6 0.5 3 gives the error:
ERROR - Unresolved overloading
*** Type : (Fractional a, Integral a) => a
*** Expression : bernoulli 6 0.5 3
Why doesn't Haskell infer the types? What kind of type casting or type definition can I use to fix the error?
Send instant messages to your online friends http://au.messenger.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070331/fe4542d3/attachment.htm
More information about the Haskell-Cafe
mailing list