Hacker News new | past | comments | ask | show | jobs | submit login

It's ugly either way but for clarity you can move the error checks into the transformation leaving the call point clean.

i.e transform1 returns (result, error) and transform2 accepts (result, error) and short-circuits if err is not nil.

It allows the expressive and succinct description of a transformation list but with a bunch of messiness hidden.




This isn't ideal, because it forces each successive function that takes a Result type to add handling code in the case of an error.

fn(fn(fn()?)?)? is a bit gnarly but better than duplicate code like that, imo.


something something Maybe monad




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: