Re[2]: [Haskell-cafe] Reading integers

2006-09-07 Thread Bulat Ziganshin
Hello Neil, Thursday, September 7, 2006, 1:45:03 AM, you wrote: Currently I have a single module that provides reading operations for Integers and Ints. I'm not quite sure what to do with it. Get it into base! Where it is, or what its called is less relevant - perhaps entirely decoupled

Re: Re[2]: [Haskell-cafe] Reading integers

2006-09-07 Thread Lennart Augustsson
What about negative numbers? Also, don't use (ord c - ord '0'), it doesn't work with Unicode digits. That's why there is a digitToInt function. -- Lennart On Sep 7, 2006, at 02:12 , Bulat Ziganshin wrote: readI = foldl f 0 where f m c | isDigit c = fromIntegral (ord c - ord '0')

Re: Re[2]: [Haskell-cafe] Reading integers

2006-09-07 Thread Bertram Felgenhauer
Lennart Augustsson wrote: Also, don't use (ord c - ord '0'), it doesn't work with Unicode digits. That's why there is a digitToInt function. FWIW, in Haskell 98, isDigit and digitToInt are defined as isDigit c= c = '0' c = '9' digitToInt :: Char - Int digitToInt c |

Re: Re[2]: [Haskell-cafe] Reading integers

2006-09-07 Thread Brian Hulley
Bertram Felgenhauer wrote: I can't comment on why Bulat doesn't like negative numbers. Neither it seems, did the original Haskell committee - that's why we have to muddle along with a confusing unary minus operator instead of proper negative literals - see the thread beginning