0

Basically what is said in the title.

I would like to input

4 6 17 4

and it would give me the list

[4, 6, 17, 4]
0

1 Answer 1

3
main = do
  ln <- getLine
  let ints = map read (words ln)  :: [Int]
  ... do something with ints...

ints is a list of Int values.

The type signature :: [Int] is needed so read knows what to return.

Sign up to request clarification or add additional context in comments.

4 Comments

Couldn't match type [] with IO Expected type: IO Int Actual type: [Int] …
@JohnDoe The code in this answer doesn't cause that error, so it must be in a different part. Which expression does the error message say has the error?
I just attempted to output the set "ints". And I get this error. I don't understand, I did it as I normally would in the console
How do I output set to console and not string?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.