Opened 7 years ago

Closed 7 years ago

#4375 closed bug (fixed)

read :: String -> StdGen behaves oddly with respect to documentation.

Reported by: ConorMcBride Owned by: igloo
Priority: normal Milestone: 7.0.2
Component: libraries (other) Version: 6.12.3
Keywords: Cc: conor@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Documentation bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

Says the documentation:

"read may be used to map an arbitrary string (not necessarily one produced by show) onto a value of type StdGen"

but this is manifestly not the case, as

read "more than 6 characters"

causes a "no parse" failure.

In fact, the *reads* implementation takes at most 6 characters from the string, rather than consuming all the input, so reads works but read fails.

It is certainly possible to work around this issue by substituting (read . take 6) for the offending read uses, but the documentation might perhaps be updated to reflect the truth.

Or perhaps the truth might be updated to reflect the documentation? I suppose it's a question of serialization versus generation. I certainly think it would be handy to generate StdGen seeds from arbitrary strings, but that should perhaps not be the function of the Read instance.

Change History (3)

comment:1 Changed 7 years ago by ConorMcBride

Cc: conor@… added

comment:2 Changed 7 years ago by igloo

Description: modified (diff)
Milestone: 7.0.2
Owner: set to igloo

Thanks for the report; I'll improve the docs.

comment:3 Changed 7 years ago by igloo

Resolution: fixed
Status: newclosed

Actually, already fixed by:

Wed Oct 13 19:12:57 BST 2010  Ian Lynagh <>
  * Improve Read docs; spotted on the mailing lists
Note: See TracTickets for help on using tickets.