I was attempting to understand the example given at this question about variadic functions and tried to modify the code from:
class SumRes r where
sumOf :: Integer -> r
instance SumRes Integer where
sumOf = id
instance (Integral a, SumRes r) => SumRes (a -> r) where
sumOf x = sumOf . (x +) . toInteger
to this:
class SumRes r where
sumOf :: Int -> r
instance SumRes Int where
sumOf = id
instance (SumRes r) => SumRes (Int -> r) where
sumOf x = sumOf . (x +)
I get a Illegal instance declaration for SumRes (Int -> r)
. Can someone explain what this means and what is the constraint I'm against?