Search code examples
haskellmoduleprogram-entry-point

Haskell... parse error on module


what can be wrong with this? I've tried multiple solutions but it all ends up with the error on 'module' and in the = sign after the main. what the heck?!?!?!

printTabuleiro :: [[Char]] -> IO()
printTabuleiro [] = []
printTabuleiro (l :lt) = putStr l : printTabuleiro lt

module Main where

main = let 
          a = ["#####\n","###o##\n"] 
       in do printTabuleiro a

now I get this compiling errors, I do not understand the type matching issues here. Btw, I'm fairly new and not used to functional don't cannonize me to mars please.

[1 of 1] Compiling Main             ( visualisacao.hs, interpreted )

visualisacao.hs:14:27:
    Couldn't match expected type ‘IO ()’ with actual type ‘[IO ()]’
    In the expression: putStr l : printTabuleiro lt
    In an equation for ‘printTabuleiro’:
        printTabuleiro (l : lt) = putStr l : printTabuleiro lt

visualisacao.hs:14:38:
    Couldn't match expected type ‘[IO ()]’ with actual type ‘IO ()’
    In the second argument of ‘(:)’, namely ‘printTabuleiro lt’
    In the expression: putStr l : printTabuleiro lt
Failed, modules loaded: none.

Solution

  • You need to declare your module first. Then you need to declare your imports. Then you can define your functions.