Name: Anonymous 2007-04-12 15:27 ID:yhED11h4
I have this function:
When I try to use it somewhere, GHC complains:
|code] Ambiguous type variable `a' in the constraints:
`RealFrac a' arising from use of `secondsToUnit'
`Integral a' arising from use of `secondsToUnit'
Probable fix: add a type signature that fixes these type variable(s)[/code]
The problem is, I'm still a newbie and I have no idea what kind of type signature I should use, since I don't completely understand Haskell's numeric types yet. Any pointers? Can it even be fixed just by adding a proper type signature or is there something else I need to alter?
secondsToUnit seconds n = let multiplier = foldl1 (*) [ [1,60,60,24] !! x | x<-[0..n] ]
units = floor $ seconds / multiplier
rest = seconds - units * multiplier
in
(units, rest)When I try to use it somewhere, GHC complains:
|code] Ambiguous type variable `a' in the constraints:
`RealFrac a' arising from use of `secondsToUnit'
`Integral a' arising from use of `secondsToUnit'
Probable fix: add a type signature that fixes these type variable(s)[/code]
The problem is, I'm still a newbie and I have no idea what kind of type signature I should use, since I don't completely understand Haskell's numeric types yet. Any pointers? Can it even be fixed just by adding a proper type signature or is there something else I need to alter?