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

Dude, if you wanted to open a file and read the first line, then just do so. What you're doing is try to derive this simple task in a cery complicated matter full of weird symbols that, even if you don't believe it, are not entirely obvious. People who want the first line of a file want something that expressed that in an obvious matter, not with a baggage of functional programming theory.


> Dude, if you wanted to open a file and read the first line, then just do so.

After knowing how the Monads and Functors work, I can:

    putStrLn =<< head . lines <$> readFile "/etc/issue"
There are advantages to separating pure and impure functions. Pure functions can be tested more aggressively with property testing for instance. They can also be optimized more agressively.

Most of the errors in software in my experience come from impure functions, so handling it in a principled way seems to reduce bugs.

> People who want the first line of a file want something that expressed that in an obvious matter

I feel like you mean to say "want something that expressed that in a familiar matter". The Haskell definition I used at the beginning of this comment is obvious to someone familiar with the basics of the programming language.

> not with a baggage of functional programming theory.

What functional programming theory? To put this into OOP terms this is just working with well defined Objects that adhere to an interface and whose failures are encapsulated in a sensible way.

edit: I agree it's harder to see or explain these advantages. Please give the tutorial I posted a quick once-over and let me know what you think. If you have specific criticisms about smaller and more specific pieces I think we could have good discussion.

To be honest I'm constantly re-assessing whether it's worth having to deal with the "baggage" of Haskell as you refer to it. However I go back to using other less principled languages and things simply don't ever seem to work out as well.




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

Search: