Skip to content

Blog

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.

Go Function Return Values: List, Not Tuple

Recently, I suddenly found that the following code line is weird, how could it pass (int, error) to ...any?

func main
func variadic(a ...any) {
    fmt.Println(a)
    return
}

func array(a []any) {
    fmt.Println(a...)
    return
}

func main() {
    variadic(json.Marshal(""))
    // array(json.Marshal(""))
    // ^ CANNOT PASS COMPILE
}

Symbol Table and Context Value Implementation

After learning briefly about compiler, with the motivation of walker inside astjson, it's a bit compulsory to master some knowledge about symbol table as it helps to understand management of variables/states in a large different scales.

This blog talks first about the symbol table itself, and then check how Go language maintains the values among contexts in src/context. Note that it doesn't talk anything else rather than values in context.

Go Type System and Type Conversion

A Failure of Assignment

Recently, my friend asked me a question, why inthe following go code, b cannot be assigned to f? With knowledges about AST, I got intrigue on it than ever before.

type (
    Bar string
    Foo Bar
)

func main() {
    var f Foo
    var b Bar
    f = b
}
/main.go:17:6: cannot use b (variable of type Bar) as type Foo in assignment
func main() {
    var f Foo = "foo"
    var b Bar
}

The failure is caused by Bar and Foo are not same type, hence, they cannot be assigned to each other. However, assign a string to Bar or Foo directly is valid.

This blog talks why the conversion fails and will introduce the type, type definition, properities of types with some examples.