[Haskell-beginners] Couldn't match expected type `(a0 -> [a0]) -> [a0]', with actual type `[a0]'

Roelof Wobben r.wobben at home.nl
Sat May 23 06:58:50 UTC 2015


Hello,

For some reasons my file's are corrupted.
I had repair them with success except this one.

Here is the code :

toDigits  number
   | number <= 0   = []
   | otherwise     = toDigits' [] number
   where
     toDigits' acc 0  = acc
     toDigits' acc number   = ((number `mod` 10 ): acc) (toDigits' 
(number `mod` 10))

main = print $ toDigits 123


and here is the error:

Couldn't match expected type `(a0 -> [a0]) -> [a0]'
                 with actual type `[a0]'
     The function `(number `mod` 10) : acc' is applied to one argument,
     but its type `[a0]' has none
     In the expression:
       ((number `mod` 10) : acc) (toDigits' (number `mod` 10))
     In an equation for toDigits':
         toDigits' acc number
           = ((number `mod` 10) : acc) (toDigits' (number `mod` 10))


Roelof


---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
http://www.avast.com



More information about the Beginners mailing list