I am trying to make a list with Points (a datatype that I created), the idea is add an element in each iteration. Something is wrong.
I have tried to put p
out of myLoop
but it doesn't seems to work either.
main = myLoop
myLoop = do
let p = []
done <- isEOF
if done
then putStrLn ""
else do inp <- getLine
let (label:coord) = words inp
p ++ [Point label (map getFloat coord)]
-- print (pointerList)
myLoop
I am getting this output
trabalho.hs:30:23: error:
• Couldn't match type ‘[]’ with ‘IO’
Expected type: IO Point
Actual type: [Point]
• In a stmt of a 'do' block:
p ++ [Point label (map getFloat coord)]
In the expression:
do inp <- getLine
let (label : coord) = words inp
p ++ [Point label (map getFloat coord)]
myLoop
In a stmt of a 'do' block:
if done then
putStrLn ""
else
do inp <- getLine
let (label : coord) = ...
p ++ [Point label (map getFloat coord)]
....
|
30 | p ++ [Point label (map getFloat coord)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^