by flowerlad · 5y ago · 0 comments
I would like to see a course or textbook that explains functional programming in the abstract. Instead of going into the details of any one functional language, gives examples of how various functional languages implement the various core ideas of functional programming.
So, explain functional programming concepts such as pure functions, referential transparency, functors, monoids, monads, effects, lazy evaluation and so on, not in the context of any specific language, but giving examples from multiple functional languages.
In other words, focus on functional programming in general, instead of one specific implementation of it. I have been looking for such a textbook or course, but it doesn't exist.
Lots of developers are curious about functional programming. Even if you don't program in a functional programming language, many principles of functional programming, such as pure functions, can be applied in any language. Almost all languages in use today, including JavaScript, C#, Java, Python and Rust have varying degrees of FP features. Understanding what FP is all about is helpful in learning those features.
I'd argue that the market for learning what FP is all about, and how you can apply FP features in traditional languages, is bigger than the market for learning specific FP languages such as OCaml, Scala, F# and so on.
https://www.lihaoyi.com/post/WhatsFunctionalProgrammingAllAb...
(edit) a post that uses JS, PHP, Python etc. to explain many FP concepts: http://chriswarbo.net/blog/2015-01-18-learning_functional_pr...
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.
* 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.