Skip to content

2024

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.

Go Reflect: Fail to Set Argument Value 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)