Repository navigation
read :: StdGen fails for strings longer than 6 #59
Description
Activity
- The documentation in read or in random. ? I do strongly recommend using the pcg package for Rng engineering today. The next major release of random will have pcg as one of the default options. I’m not sure what you’re trying to do with reading here? It doesn’t look like a deserialize to me ?…On Tue, Mar 10, 2020 at 11:11 AM Joey Hess ***@***.***> wrote: ghci> read "abcdef" :: StdGen 36217 1 ghci> read "abcdefg" :: StdGen ** * Exception: Prelude.read: no parse This is contrary to the documentation: "It guarantees to succeed on any string. " random-1.1 ghc-8.6.5 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#59?email_source=notifications&email_token=AAABBQRKBWU3ALRGQMBFVTDRGZKDHA5CNFSM4LFBHSFKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IT5RK4Q>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAABBQVSK57MZW4LJT2ILG3RGZKDHANCNFSM4LFBHSFA> .
- What’s the intent or goal you want to achieve here ? That can help inform some of the planned new library work On Tue, Mar 10, 2020 at 11:51 AM Carter Schonwald < [email protected]> wrote:…The documentation in read or in random. ? I do strongly recommend using the pcg package for Rng engineering today. The next major release of random will have pcg as one of the default options. I’m not sure what you’re trying to do with reading here? It doesn’t look like a deserialize to me ? On Tue, Mar 10, 2020 at 11:11 AM Joey Hess ***@***.***> wrote: > ghci> read "abcdef" :: StdGen > 36217 1 > ghci> read "abcdefg" :: StdGen > ** * Exception: Prelude.read: no parse > > This is contrary to the documentation: "It guarantees to succeed on any > string. " > > random-1.1 > ghc-8.6.5 > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <#59?email_source=notifications&email_token=AAABBQRKBWU3ALRGQMBFVTDRGZKDHA5CNFSM4LFBHSFKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IT5RK4Q>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAABBQVSK57MZW4LJT2ILG3RGZKDHANCNFSM4LFBHSFA> > . >
It's a guarantee provided in the docs for random:
In addition, 'reads' may be used to map an arbitrary string (not necessarily one produced by 'show') onto a value of type 'StdGen'. In general, the 'Read' instance of 'StdGen' has the following properties:
- It guarantees to succeed on any string.
- It guarantees to consume only a finite portion of the string.
- Different argument strings are likely to result in different results.
This is a weird thing to do with
reads. Removing the brokenReadinstance forStdGenis a reasonable solution and deleting the associated documentation would be a reasonable fix.- Derp. Yeah. Agreed on all fronts. Been in a cavern on new random and forgot about this cute little rough edge.…On Tue, Mar 10, 2020 at 1:53 PM Andrew Martin ***@***.***> wrote: It's a guarantee provided in the docs for random <https://github.com/haskell/random/blob/22a2a16bd62edd553b4f7f2e9eedc26cbf8850d8/src/System/Random.hs#L183> : In addition, 'reads' may be used to map an arbitrary string (not necessarily one produced by 'show') onto a value of type 'StdGen'. In general, the 'Read' instance of 'StdGen' has the following properties: - It guarantees to succeed on any string. - It guarantees to consume only a finite portion of the string. - Different argument strings are likely to result in different results. This is a weird thing to do with reads. Removing the broken Read instance for StdGen is a reasonable solution and deleting the associated documentation would be a reasonable fix. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#59?email_source=notifications&email_token=AAABBQRC7WH3EVNAO5UFKA3RGZ5BTA5CNFSM4LFBHSFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOMPG4Q#issuecomment-597226354>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAABBQVQLSMI4F6A6NXBTH3RGZ5BTANCNFSM4LFBHSFA> .
I'd recommend using splitmix as
- It's the fastest
- Passes e.g. BigCrush so plenty good enough for non-cryptographic applications
- Has a good
splitfunction - Is used by QuickCheck
See here for the details on speed and quality (which you can run yourself ):
- Pcg does better on big crush last I checked than splitmix. But either is good.…On Wed, Mar 11, 2020 at 9:34 AM idontgetoutmuch ***@***.***> wrote: I'd recommend using splitmix <https://hackage.haskell.org/package/splitmix> as - It's the fastest - Passes e.g. bigCrush so plenty good enough for non-cryptographic applications - Has a good split function - Is used by QuickCheck <https://hackage.haskell.org/package/QuickCheck> See here for the details on speed and quality (which you can run yourself ): - https://alexey.kuleshevi.ch/blog/2019/12/21/random-benchmarks/ - https://github.com/tweag/random-quality/tree/master/results — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#59 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAABBQSOCATG5QVMPE4Q26TRG6HOPANCNFSM4LFBHSFA> .
Pcg does better on big crush last I checked than splitmix.
SplitMix passes all BigCrush tests: https://github.com/tweag/random-quality/blob/master/results/splitmix-word32-testu01-bigcrush#L3775-L3782
- added 7 commits that reference this issue
on May 7, 2020 - added a commit that references this issue
on May 18, 2020 1 remaining item
- added 6 commits that reference this issue
on Jun 15, 2020 Fixed.
Readinstance was removed inrandom-1.2. See #62
This is contrary to the documentation: "It guarantees to succeed on any string. "
random-1.1
ghc-8.6.5