This is because you are trying to read something with the wrong type.
You say that Line
is a String
aka. [Char]
. However, the input you enter has the format ["12", "13"]
, which looks as if it should be of type [Line]
, otherwise. [String]
or [[Char]]
.
You need to explain what Line
should be. If you want the Line
line to be a line, then why do you enter lists of lines in the terminal? Something is wrong with your logic in this case.
If you want to use the square matrix input method, you can enable one of the following formats instead of type Line = [Int]
:
-- What you type at the terminal: 1 -2 3 4 5 6 6 7 8 -- How to read it in your program: line <- (map read . words) `fmap` getLine -- What you type at the terminal: [1, -2, 3] [4, 5, 6] [6, 7, 8] -- How to read it in your program: line <- readLn
If you really want to enter lines, so that type Line = [Char]
and that every number in the input list becomes a Unicode character, which means that when you enter [97, 98, 99]
on the terminal, you will get the string "abc"
:
source share