[Haskell-beginners] Couldn't match expected type ‘IO ()’ with actual type [Integer]
Nadir Sampaoli
nadirsampaoli at gmail.com
Thu Feb 5 12:26:54 UTC 2015
"Roelof Wobben":
>
> I have this :
>
> -- | Main entry point to the application.
> module Main where
>
>
> -- | convert a number to a array in pieces where a negative number will
be a empty array.
> toDigits :: Integer -> [Integer]
> toDigits n
> | n < 0 = []
> | otherwise = n/10 : []
>
> -- | The main entry point.
> main :: IO ()
> main = do
> toDigits 123
First of all, what do you expect from your program?
The problem with your code is that `main` declares type `IO ()` in its
signatures but its body has another type, [Integer].
What do you think is wrong with the compiler's output?
--
Nadir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20150205/d59faff0/attachment.html>
More information about the Beginners
mailing list