Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Type signature faggotry

Name: Anonymous 2007-04-12 15:27 ID:yhED11h4

I have this function:

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?

Name: Anonymous 2007-04-12 17:43 ID:vg7TDEA+

Someone code a one line haskell version.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List