[Haskell-beginners] Couldn't match expected type ‘IO ()’ with actual type [Integer]

Max Voit max.voit+mlhb at with-eyes.net
Thu Feb 5 12:01:50 UTC 2015


Hi Roelof,

On Thu, 05 Feb 2015 12:37:12 +0100
Roelof Wobben <r.wobben at home.nl> wrote:

> main :: IO ()
> main = do
>     toDigits 123

> src/Main.hs at 14:5-14:17
> Couldn't match expected type ‘IO ()’ with actual type
> [Integer]
> … In a stmt of a 'do' block: toDigits 123 In the expression: do
> { toDigits 123 }

since your do block consists only of one expression,
actually your main looks like:

main :: IO ()
main = toDigits 123

Perhaps this explains where the problem lies.

Considering, however, do-notation: The last statement of a do-block
needs to be an expression of the type of the do-block. Translating
do-notation to bind operator sequences[1] may be helpful in
understanding this.

best,
Max

[1] http://en.wikibooks.org/wiki/Haskell/do_notation


More information about the Beginners mailing list