# Having contraints like 'Fractional Int => IO ()'

**Jesper Louis Andersen
**
jlouis@diku.dk

*Tue, 13 Nov 2001 03:06:15 +0100*

This problem has had my attention for a while now. I hope someone would
like to help me out on the problem.
I have a simple average function defined as:
mean :: (Fractional a) => [a] -> a
mean l = (sum l)/ fromIntegral (length l)
Which imposes a type constraint (of course). My problem is, that i
cannot ``let go'' of this constraint. The constraint travels through the
call tree of my functions and ends at the top-level function, which is
defined as a Monad (I need some IO operations on some files). Now, I
have tried to solve the problem, but the closest I have got is to make
my main function be of type:
main :: Fractional Int => IO ()
But that is not something that Hugs likes as it tells me that I have a
``unresolved overloading'' at the expression ``main'' on the type.
So... Is there a way to get rid of the constraint by converting the
function to something more sensible. I seem to have missed a point here,
as I have migrated from Standard ML to Haskell (the latter being a far
more complicated language it seems). As SML doesn't have type classes,
they seem to have bitten me hard. If anyone could point to the relevant
information, it would be very nice.
Thanks in advance
--
Jesper