Skip to content

Blog

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.

Fail to Reflect Set During Conversion

This blog records the failure when trying to set the response value using reflect to provide an adaptor for wrapping the original PRC interceptor to the custom interceptor format defined by our tech products.

The difference between them is the custom interceptor moves the response from an argument to a response. This blog introduces the challenges encountered while designing an adaptor.

Signatures of Original RPC Interceptor And Custom Interceptor
// package rpc
// original RPC interceptor signature
type Interceptor func(ctx context.Context, 
    request, response interface{}, processor Processor) uint32
type Processor func(ctx context.Context, request, response interface{}) uint32


// package custom
// interceptor in the tech team
type CustomInterceptor interface {
    Wrap(HandlerFn) HandlerFn
}
type HandlerFn func(ctx context.Context, req interface{}) (interface{}, error)

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

LLVM and GC

In this blog, I will introduce how I integrate a precise, relocation GC with LLVM using its statepoint api. We will also talk about some optimization techniques, debug support and so on.