Skip to content

Haskell Language

Understand Monad Transformers

Monad transformer(monadT) is another significant concept in Haskell. To understand the monadT, it's compulsory to know how monad works and the mechanism of >>=(bind). You can view the blog Understand Monad or any popular monads to learn about them.

In this blog, I will convey how we use monad transformer while how we recognize the idea that monad transformer creates a new monad. I will explain the function lift as well.

Understand Monads

Monad is a fundamental concept in Haskell. Recently, I have reviewed them and made my mind clearer. Hence, I wrote down this blog. To understand them, we need to clearly understand some concepts, such as:

  • understand the do notation syntax sugar and learn about how de-sugar it to >>= format
  • understand the closures after de-sugaring
  • type constructor
  • understand how the >>= deals with the data held inside a monad
  • understand the runMonad function properly
  • clarify the difference between monad in category(math) and the monad in haskell

Setting Up Debugger for Haskell in Vscode

It's not easy as the other languages which owns an IDE so click the button is the only thing need to do. Using Vscode, I installed several plugins and dependencies, then clicked debug button, oops, nothing happened! The debugger bar flashes and disappear, then nothing happened except the confusing people at the front of screen.

To be frank, I gave up several times when I was attacked by such a messy event. However, another afflict when I want to diagnose my program. After plowing in the troublesome problems, I finally set up it successfully. However, it becomes more messy when I changed my Desktop from Intel to M1, which means I need to set it up AGAIN.

This blog records some hints for setting up Haskell Debugger. I hope I will never set it up with so many trouble again.

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.

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.