Re: Correct parsers for bounded integral values

Tom Smeding <[email protected]> Sun, 13 Jul 2025 14:06:58 +0200
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
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 

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.