I can do the following:
Prelude> reads "1 2 3" :: [(Int, String)]
[(1," 2 3")]
Prelude> reads "(1,2) (3,4)" :: [((Int, Int), String)]
[((1,2)," (3,4)")]
Prelude> reads "(1,2)(3,4)" :: [((Int, Int), String)]
[((1,2),"(3,4)")]
Prelude> reads "(1,2)\n(3,4)" :: [((Int, Int), String)]
[((1,2),"\n(3,4)")]
Prelude> reads "(1,2) (3,4)" :: [((Int, Int), String)]
[((1,2)," (3,4)")]
I can derive Read and get reads to read those too. But I’ve never gotten reads to return more than one tuple in the list. Why does reads return a list?
None of the standard instances do so, but it’s intended for ambiguous parses; since this is not really very useful, and parsers that use this functionality would be very inefficient,
reads‘s return value is for all practical purposes aMaybemasquerading as a[].The Report’s definition of
readreveals the intended meaning of multiple parses:So: historical reasons, basically.