2 ms·
Couldn't agree more! ... I just had to laugh to myself at how this, THIS is why functional programming is so... rarely adopted. Like, "referentially transparent
by kbuchanan 7y ago
Couldn't agree more! ... I just had to laugh to myself at how this, THIS is why functional programming is so... rarely adopted. Like, "referentially transparent functions"?! What happened to `website.run.now!`?!
- lemmsjid 7y agoReferential transparency is a handy thing to think about in OOP as well as functional programming. If you provide the same parameters to a function, will you always get the same result? If yes, and if the function is 'pure', e.g. does not result in some side effect like state manipulation, you could replace the function itself with the output of that function. If so, and the function is computationally expensive, you can memoize the function, which is a specific form of caching where you auto cache the results by the parameters passed to the function. This is a handy chain of reasoning in any language, and in a more dedicated functional language might be supported as a concept in the language itself. Like in OOP, you don't have to have that term memorized to actually use a functional language, just remember the pattern.
- tome 7y agowebsite.run.now is referentially transparent in Haskell (or rather, to mention the one I use, Happstack.Lite.serve: https://hackage.haskell.org/package/happstack-lite-7.3.6/docs/Happstack-Lite.html https://hackage.haskell.org/package/happstack-lite-7.3.6/doc...)