Skip to content

Blog

Precise Lose Between Float64 and Uint64

In astjson library, the lexer scans the number and stores the respective bytes. Then the parser will parse the bytes to number which is expressed by a float64. It works well at beginning, however, once I added a corner case of number with value math.MaxUint64(1<<64 - 1 or decimal value 18446744073709551615), the parser cannot work as expected. It's indeed a bug issue.

The simplified problem is the value through debug of f is 18446744073709552000 instead of 18446744073709551615.

f, _ = strconv.ParseFloat("18446744073709551615", 64)

Tar Wrapped by Cli Tool Fails to Write

Our internal CLI tool will try to download a proto file by git achieve command, and then tar it to /usr/local/include. One user reported in his desktop tar cannot unzip file:

xxx.proto: Can't create 'xxx.proto'
tar: Error exit delayed from previous errors.
ERROR fail to extract xxx.proto into '/usr/local/include/xxx.proto' 
via this script: 'tar -xf xxx.tar -C /usr/local/include'.

Type and Typeclass in Haskell

When I was reading the haskell aeson library implementation, I still a little confusing with type system especially for multiple constructors.

Hence, I learned it again and record some ideas here. It reviews the value constructor, type constructor and the strict type in type constructor.

Developing Notes of ASTJSON Library

After reading about the compiler, I feel intrigued as it challenges me with numerous design and implementation details. It's an exciting topic for me. Inspired by the APIs the Haskell Aeson library exposed, it's a good practice for me to write a toy library named xieyuschen/astjson to parse JSON string to AST in a slightly functional way. This is a developing notes page, and I record some reflections.

Is Maybe Int More Expressive Than Int in Set Thoery?

This question seems intuitively and undoubtedly correct as long as you have used Maybe Int in your code. The first brief glance brings us that Maybe Int has 1 additional case more than Int as the former could present Nothing but the latter cannot. Hence, the Maybe Int is more expressive than Int.

In this blog, I will try to figure out the anwser with set theory knowledge. However, I should acknowledge the set theory could not solve this question, which might lead you a bit more confusing after reading this blog. It's wrote down to reflect how I thought the problem.