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

Roelof Wobben r.wobben at home.nl
Thu Feb 5 12:25:16 UTC 2015


Max Voit schreef op 5-2-2015 om 13:01:
> 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
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

Thanks,

Another question :  how can I display the array ?

putStrln works only for strings,

Roelof



More information about the Beginners mailing list