[Haskell-cafe] Correct parsers for bounded integral values

Tom Smeding x at tomsmeding.com
Sun Jul 13 12:06:58 UTC 2025


On 13/07/2025 13:34, Stefan Klinger wrote:
> Unfortunately, I got a bit lost when trying to track down the code of
> `read` in the `base` package.

Fortunately, this at least is easily answerable. Going here for the Read 
class [1], scrolling down to the Read Int instance and clicking 'Source' 
leads one here [2]; subsequently clicking through to the definitions of 
readNumber and convertInt should lead you to the actual parsing code. It 
is implemented in terms of a ReadP parser.

- Tom

[1]: 
https://hackage.haskell.org/package/base-4.21.0.0/docs/GHC-Read.html#t:Read
[2]: 
https://hackage.haskell.org/package/ghc-internal-9.1201.0/docs/src/GHC.Internal.Read.html#line-586 



More information about the Haskell-Cafe mailing list