Haskell problem with IO function accepting return value from a another function?

You can't use the notation for assigning the return values of sum' m and x/length m can only be used when the right-hand side is a monadic expression (in this case, an IO value), which neither one is, and so you should use let x = sum' m and let avg = x / fromInteger (length m) instead ( fromInteger is needed to convert the Int returned by length m to a Fractional value so it can be passed to ). (Also, you need to change x /= to m /= ).

Thanx jwodder! But I still can not let calculate the average I getting error ERROR file:. \PRO.

Hs:10 - Type error in application *** Expression : fromInteger (length m) *** Term : length m *** Type : Int *** Does not match : Integer – visuddha Jun 12 at 3:16 1 @visuddha use fromIntegral to coerce integral types. – Thomas M. DuBuisson Jun 12 at 4:10.

Module PRO where average1 :: IO () average1 = do putStrLn "Enter Marks in Form of a List" marks a -> a sum' xs = foldl (\acc x -> acc + x) 0 xs i) The type signature of average1 is incorrect, the function does not return a value ii) Edit: this point was incorrect iii) the average value is a float, so you need to cast the integer arguments iv) Your test if (x/=) is the wrong way round and should use m not x v) most of your lines are not in the IO monad and so should use let inside a do block.

MacPhail thanks a lot for your help. The code compiled no problem but I still get a run time error saying PRO> average1 Enter Marks in Form of a List 1,2,3 Your Avarage is Program error: Prelude. Read: no parse – visuddha Jun 12 at 3:27 @jwodder @Vivian McPhail got it, thanks for the help you guys provided.

You rock! – visuddha Jun 12 at 3:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions