DEV Community

Discussion on: Is Haskell bad for FP?

Collapse
 
filipposestini profile image
Filippo Sestini

we cannot eagerly evaluate repeat 1 on a different thread without risking doing unnecessary work

The idea of evaluating things in parallel to save time makes more sense in an eager language.
In a lazy language, laziness is your optimization. You don't need to optimize thunks that you never evaluate. Moreover, laziness gives you memoization for free in many cases. Generally, laziness gives you better asymptotics than eager evaluation, which instead systematically confines you to worst-case complexity.

It can, but various 'pragmatic' decisions, e.g. undefined, Any, unsafeCoerce, unsafePerformIO make me believe it isn't.

Even dependently typed languages designed to be sound logics have escape hatches.
The PL community has come a long way, but sometimes you just need to throw in the towel and admit that you know more than the machine about your program.
Haskell programmers know that unsafe functions are unsafe, and should only be used in specific instances where it is known that they do not lead to unsoundness. Trying to suggest that Haskell is no more pure than C because of unsafePerformIO is a ridicolous proposition.

Also, what do you mean by Any?

Rather it is a language by academics and for academics.

This has stopped being true years ago, and is now factually wrong. For example, the majority of members of the GHC steering committee is from the industry.

Thread Thread
 
drbearhands profile image
DrBearhands • Edited

The idea of evaluating things in parallel to save time makes more sense in an eager language.
In a lazy language, laziness is your optimization [...]

No argument there!

sometimes you just need to throw in the towel and admit that you know more than the machine about your program

Again, we are in agreement. The point is that there is a design choice here. Should the programmer sometimes jump through hoops to appease the compiler in order to gain very strong guarantees? Different situations prefer different answers.

Trying to suggest that Haskell is no more pure than C because of unsafePerformIO is a ridicolous proposition.

Not saying that! Closest thing I would argue is echoing The C language is purely functional, where purity is considered a binary property, not a quantitative one. Beyond that, it's mostly a matter of trust.

Also, what do you mean by Any?

It's a type in Haskell that can be cast to/from any other type. Useful e.g. when implementing an open sum.

Rather it is a language by academics and for academics.

This was more a comment about the "soul" of the language than usage statistics.

I'd like to emphasize that the point of the post, which I utterly failed to bring across, is not that Haskell is bad, certainly not compared to existing languages (it is my favorite language ATM). Instead, I'd wanted to say that its dominant position is causing people to equate purely functional programming to Haskell, but Haskell has made many choices beyond functional purity that are not necessarily pareto-dominant. So while I believe functional purity (not quite that, but close enough) is always the right answer, Haskell is not.

EDIT: fixed mistake, wrote pareto-optimal when I meant pareto-dominant.

Thread Thread
 
filipposestini profile image
Filippo Sestini • Edited

It's a type in Haskell that can be cast to/from any other type. Useful e.g. when implementing an open sum.

I still have no idea what you are talking about. Afaik there are no Any types in the Haskell standard or in base, so you will have to link to it.

If you mean the Any type that you can define as an existential, like Dynamic, there's nothing unsafe about it.