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

I once asked a FP enthusiast and the answer was it makes formal reasoning about the code easier.


As a small demonstration of the principle: https://github.com/system-f/fp-course#demonstrate-io-maintai...

Scroll past the Haskell example for a moment and look at the Python. The program p2 is the same as p1, except a refactoring is performed: the call to readFile(file) is DRY'd into a variable, and this changes the meaning of the program.

In the Haskell example, the same refactoring is performed. Because IO actions are treated as values in their own right, the refactoring does not change the meaning of the program. Executing p1 or p2 will have the same effect.




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

Search: