Hacker News new | ask | show | jobs
by greenbast 3628 days ago
The Go code in your example could actually be written:

    resp, err := http.Get(someURL)
    if err != nil {
        return nil, err
    }
    return DoStuff(resp)
1 comments

Yeah, but if you had 5 operations in Haskell, you'd write:

    do
        a <- operation1
        operation2 a -- This one returns nothing
        b <- operation3 a
        c <- operation4 b
        operation5 c
In Go, you'll keep repeating that 'if err != nil {' everywhere. And things get way more interesting with more complex monads, but error handling is simple.