J'ai l'expression suivante :
getCount :: (Num a) => a -> [a]
getCount int = foldl
processOneCount
[0,0,0,0,0,0,0,0,0,0]
(map (singleDigitCount) (map (digitToInt) (show int)))
et j'obtiens l'erreur suivante :
Couldn't match expected type `a' against inferred type `Int'
`a' is a rigid type variable bound by
the type signature for `getCount'
at C:\Users\RCIX\Desktop\Haskell Code\test.hs:23:17
Expected type: [a]
Inferred type: [Int]
In the expression:
foldl
processOneCount
[0, 0, 0, 0, ....]
(map (singleDigitCount) (map (digitToInt) (show int)))
In the definition of `getCount':
getCount int
= foldl
processOneCount
[0, 0, 0, ....]
(map (singleDigitCount) (map (digitToInt) (show int)))
Pourtant, lorsque je fais une :t [0,0,0,0,0,0,0,0,0,0]
je reviens [0,0,0,0,0,0,0,0,0,0] :: (Num t) => [t]
. Alors pourquoi je ne peux pas l'utiliser dans la première expression ?