by adamwk · 5y ago · 0 comments
These three things are mostly Haskell-specific though, at least in relation to functional programming.
https://docs.rs/functional/0.0.5/functional/trait.Functor.ht...
https://docs.rs/functional/0.0.5/functional/trait.Monoid.htm...
https://docs.rs/functional/0.0.5/functional/trait.Monad.html
The only real requirement of functional programming is the support of first class functions, the possibility to pass and return functions like any other values.
If you want to discuss your own interpretation of what makes a language more or less functional, which could be interesting, please provide a definition first.
IMHO, a functional programming language requires:
- First-class functions and function literal (lambda) syntax support
- Expression-oriented syntax
- Emphasis on immutable data structures
- Tail call optimization
Other features are 'take-it-or-leave-it'.
By that definition C language supports functional programming. I think a lot of people would disagree with your definition.
* it's a bit more verbose.
* you can accidentally implement a weaker interface than the one you'd want, e.g. by only implementing Functor and not Traversable for your data structure.
* the flip side of the benefits is that adding I/O to a previously pure function changes its interface.
I don't know how it'd compare to OCaml's algebraic effects proposal, though.
[0]: https://reactjs.org/docs/hooks-effect.html
[1]: http://joeduffyblog.com/2010/01/03/a-brief-retrospective-on-...
Having to use monads for sequencing is something that happens in Haskell and not in Rust.