Fwd: [Haskell-cafe] A simple question

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Wed Nov 3 07:35:16 EST 2004

On Wed, 3 Nov 2004, Marc Charpentier wrote:

> Thank you all for the friendly and helpful explanations - and for your 
> patience.
> The solution to my problem is finally
> 		f :: Double -> Double
> 		f i = (-1)**i/(2**(10*i)) * (-2^5/(4*i+1)-1/(4*i+3)+2^8/(10*i+1) 
> -2^6/(10*i+3)-2^2/(10*i+5)-2^2/(10*i+7)+1/(10*i+9))

I'm afraid that you will get problems with negative bases if you use (**) 
which allows fractional exponents. If your function is inherently based on
positive integer i's you should stick to (^). Further on you should use
one of the signatures

 f :: Integral a => a -> Double
 f :: Int -> Double
 f :: Integer -> Double

to assert statically that f will always receive integer values and nothing

More information about the Haskell-Cafe mailing list