Sebastian Schulz wrote:
> I have a function
> 
> shorten :: (Int,Int) -> (Int,Int)
> shorten (a,b) = ( a/(ggt a b) , b/(ggt a b) )
> 
> where ggt is a function which calculates the biggest common divisor of
> two integers with the following type:
> 
> ggt :: Int -> Int -> Int
> 
> When I want to load this into hugs98 the following error appears:
> 
> error: Instance of Fractional Int  required for definition of shorten
> 
> I thought that it is no Problem to use the '/' operator with two Ints.
> So what is wrong with my functions?

Hi Sebastian,

if you try 

:t (/) 

you will see:

(/) :: Fractional a => a -> a -> a

This says that the arguments to (/) must be fractionals (like Float and Double).
If you want to divide Int, use div.

:t div
div :: Integral a => a -> a -> a

try 

        shorten (a,b) = ( a `div` (ggt a b),b `div` (ggt a b))

Hope this helps!

Andy Gill

Reply via email to