Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was just comparing the pattern matching from FP languages with the more primitive C-like switch statement. The big advantage comes from the algebraic data types (tagged unions), which let you model data with many "cases" in a type-safe manner. For example, in Haskell we don't have null pointers because we can use the Maybe type instead.

The case-expression vs function-definition difference you mentioned from Haskell is just syntactic sugar. In both situations you are doing exactly the same pattern matching under the hood.



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

Search: