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.
You need to declare your module first. Then you need to declare your imports. Then you can define your functions.
The module
declaration can only be preceded by comments and compiler pragmas like language extensions. Put the module Main where
line at the top of your file and everything else below it. Imports must also come between the module declaration and any function or type declarations, so it should look like
module Main where
import Data.Char
import ...
printTabuleiro :: ...
printTabuleiro [] = ...
main = let
a = ...
in do printTabuleiro a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With