I need to use the map function to get for example pence to pounds conversion.
Sorry for the stupid question.. but I am a beginner.
del :: Int -> Float
del x = ( fromIntegral x ) / 100
pounds :: [Int] -> [Float]
pounds = map del
and I get this error..
*Main> pounds 45
<interactive>:90:8:
No instance for (Num [Int])
arising from the literal `45'
Possible fix: add an instance declaration for (Num [Int])
In the first argument of `pounds', namely `45'
In the expression: pounds 45
In an equation for it': it = pounds 45
It seems you typed
at the prompt. But
poundsexpects a list (ofInt) as its argument. You should either usethere, or
Since integer literals have an implicit
fromInteger, GHC tries to find the conversionfromInteger :: Integer -> [Int], which would require aninstance Num [Int], but it can’t find one, that’s the error it reports.