Burning more bridges (mostly numeric ones)

Henning Thielemann schlepptop at henning-thielemann.de
Sun Mar 23 18:30:07 UTC 2014


Am 23.03.2014 19:16, schrieb Tom Ellis:
> On Sun, Mar 23, 2014 at 01:50:43AM -0700, Bart Massey wrote:
>>>>>> :m + Numeric.Lens Control.Lens
>>>>>> "7b" ^? hex
>>> Just 123
>>>>>> hex # 123
>>> "7b"
>>
>> Nice. Once this really becomes standard, I guess we'll be somewhere.
>
> Unless there's some way I'm unaware of to statically verify that the string
> indeed represents a valid hex encoding, then this is still not a complete
> solution.

Since the original complaint was about parsing, there must be a way to 
fail. The first line ("7b" ^? hex) seems to allow failure.

For literal hex input we have 0x7b.


However I don't see a problem with readHex.

Prelude> case Numeric.readHex "7b" of [(n,"")] -> print n; _ -> putStrLn 
"could not parse hex number"

123



More information about the Libraries mailing list