#2470: read for StdGen fails for arbitrary string
------------------------------+---------------------------------------------
 Reporter:  guest             |          Owner:         
     Type:  bug               |         Status:  closed 
 Priority:  normal            |      Milestone:         
Component:  libraries/random  |        Version:  6.8.3  
 Severity:  normal            |     Resolution:  invalid
 Keywords:  StdGen read       |     Difficulty:  Unknown
 Testcase:                    |   Architecture:  x86    
       Os:  Windows           |  
------------------------------+---------------------------------------------
Changes (by igloo):

  * status:  new => closed
  * difficulty:  => Unknown
  * resolution:  => invalid

Comment:

 Strings that are the result of showing a StdGen work fine as part of
 structures:
 {{{
 Prelude System.Random> let x = (mkStdGen 100, mkStdGen 200)
 Prelude System.Random> x
 (101 1,201 1)
 Prelude System.Random> let y = show x
 Prelude System.Random> y
 "(101 1,201 1)"
 Prelude System.Random> let z = read y :: (StdGen,StdGen)
 Prelude System.Random> z
 (101 1,201 1)
 Prelude System.Random>
 }}}

 For reading a random string you can use `reads` to avoid the exception.

 We've discussed this before, although I can't find the ticket now (it
 might have been on a mailing list or something), and concluded that given
 the "finite portion" requirement the current behaviour is the best.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2470#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

Reply via email to