#4375: read :: String -> StdGen behaves oddly with respect to documentation.
----------------------------------+-----------------------------------------
Reporter: ConorMcBride | Owner: igloo
Type: bug | Status: new
Priority: normal | Milestone: 7.0.2
Component: libraries (other) | Version: 6.12.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Documentation bug
----------------------------------+-----------------------------------------
Changes (by igloo):
* owner: => igloo
* milestone: => 7.0.2
Old description:
> 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.
New description:
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.
--
Comment:
Thanks for the report; I'll improve the docs.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4375#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs