bai*_*lus 2 haskell program-entry-point module
这可能有什么问题?我已经尝试了多种解决方案,但最终都会出现'模块'上的错误以及主要后面的=符号.有没有搞错?!?!?!
printTabuleiro :: [[Char]] -> IO()
printTabuleiro [] = []
printTabuleiro (l :lt) = putStr l : printTabuleiro lt
module Main where
main = let
a = ["#####\n","###o##\n"]
in do printTabuleiro a
Run Code Online (Sandbox Code Playgroud)
现在我得到了这个编译错误,我不明白这里的类型匹配问题.顺便说一句,我是相当新的,不习惯功能,请不要把我加入火星.
[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.
Run Code Online (Sandbox Code Playgroud)
该module
声明只能通过评论和编译器编译指示类似语言扩展之前.将该module Main where
行放在文件的顶部以及其下方的所有其他内容中.模块声明和任何函数或类型声明之间也必须有导入,所以它应该是这样的
module Main where
import Data.Char
import ...
printTabuleiro :: ...
printTabuleiro [] = ...
main = let
a = ...
in do printTabuleiro a
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3833 次 |
最近记录: |