[Haskell-cafe] Unresolved overloading error

2007-03-31 Thread Scott Brown
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)))

Re: [Haskell-cafe] Unresolved overloading error

2007-03-31 Thread Lennart Augustsson
Actually, I don't know what type you want p to be, so you might not need the fromIntegral. On Mar 31, 2007, at 10:21 , Lennart Augustsson wrote: The definition of fac forces the result to have the same type as the argument. Then in binom you use / which forces the type to be Fractional.

Re: [Haskell-cafe] Unresolved overloading error

2007-03-31 Thread Scott Brown
It's working now, thank you. I changed the definition to binom n j = div (fac n) ((fac j)*(fac (n - j))) bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j)) Lennart Augustsson [EMAIL PROTECTED] wrote: The definition of fac forces the result to have the same type as the

Re: [Haskell-cafe] Unresolved overloading error

2007-03-31 Thread Bryan Burgers
On 3/31/07, Scott Brown [EMAIL PROTECTED] wrote: It's working now, thank you. I changed the definition to binom n j = div (fac n) ((fac j)*(fac (n - j))) bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j)) As a matter of style suggestion, it might make 'binom' more clear

Re: [Haskell-cafe] Unresolved overloading error

2007-03-31 Thread Jacques Carette
Bryan Burgers wrote: On 3/31/07, Scott Brown [EMAIL PROTECTED] wrote: It's working now, thank you. I changed the definition to binom n j = div (fac n) ((fac j)*(fac (n - j))) bernoulli n p j = fromIntegral(binom n j)*(p ^ j) * ((1 - p)^(n - j)) As a matter of style suggestion, it might

Re: [Haskell-cafe] Parsing words with parsec

2007-03-31 Thread Paolo Veronelli
On Friday 30 March 2007 06:59, Stefan O'Rear wrote: Anyway, I think parsec is *far* too big a hammer for the nail you're trying to hit. In the end , the big hammer solution has become parseLine = fmap (map fst. filter snd) $ many parser where parser = do w - option (,False) parseAWord

[Haskell-cafe] HGL on Mac OS X

2007-03-31 Thread Ruben Zilibowitz
Hi, Has anyone got the GHC module HGL to work on Mac OS X? If so I'd be very interested to know how. Cheers, Ruben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe