#4502: Add a Read instance for Data.Fixed.Fixed
---------------------------------+------------------------------------------
    Reporter:  igloo             |        Owner:              
        Type:  proposal          |       Status:  new         
    Priority:  normal            |    Milestone:  Not GHC     
   Component:  libraries/base    |      Version:  7.0.1       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------
 Add a Read instance for Data.Fixed.Fixed.

 Patch and test attached; the essence is:
 {{{
 readsFixed :: (HasResolution a) => ReadS (Fixed a)
 readsFixed = readsSigned
     where readsSigned ('-' : xs) = [ (negate x, rest)
                                    | (x, rest) <- readsUnsigned xs ]
           readsSigned xs = readsUnsigned xs
           readsUnsigned xs = case span isDigit xs of
                              ([], _) -> []
                              (is, xs') ->
                                  let i = fromInteger (read is)
                                  in case xs' of
                                     '.' : xs'' ->
                                         case span isDigit xs'' of
                                         ([], _) -> []
                                         (js, xs''') ->
                                             let j = fromInteger (read js)
                                                 d = 10 ^ genericLength js
                                             in [(i + (j / d), xs''')]
                                     _ -> [(i, xs')]
 }}}

 Suggested deadline: 1 Dec 2010.

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