Hacker News new | ask | show | jobs
by lmm 2015 days ago
You don't really need language features, assuming your language has sum types, polymorphism and first class functions (and why bother using a language that's missing any of those). All you need is some functions, and you can write those yourself since they're just functions. https://fsharpforfunandprofit.com/posts/recipe-part2/
2 comments

> You don't really need language features, assuming your language has sum types, polymorphism and first class functions (and why bother using a language that's missing any of those).

To be fair, this is basically saying "you don't need language features as long as you have these language features".

Sure, but those are general language features that you'd want to have for many other reasons anyway. You don't need any option/result-specific language features.
> You don't really need language features, assuming your language has sum types, polymorphism and first class functions

Aren’t those features?

My point is that Option::ok_or and Option::map aren't language features, they're just plain old functions written in the language; if they weren't there you could implement them yourself. You need some language features to implement them (e.g. you can't implement map without first-class functions), but those are general-purpose language features that you'd want to have anyway.