Skip to content

2023

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.

Understand Functions Are Functors

Functions are functors is a basic idea in funcitonal programming. However, the (->) r formats of functions are confusing and misleading, What's worse, affected by imperative language features, there was an misunderstanding about how the original structure is hold by a functor. To be more concrete, this blog talks about the question: why result of fmap (*2) (+100) 1 is 202, not 102?