read :: String -> StdGen behaves oddly with respect to documentation.
|Reported by:||ConorMcBride||Owned by:||igloo|
|Type of failure:||Documentation bug||Test Case:|
|Related Tickets:||Differential Rev(s):|
Description (last modified by )
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.