DEV Community

Discussion on: Is Haskell bad for FP?

Collapse
 
drbearhands profile image
DrBearhands

Nowadays I write all my backend code in Haskell.

As do I! :-)
On the whole though, I'm not saying Haskell is bad compared to other existing languages. Instead, I believe FP can be a whole lot more than Haskell, and that this is currently not properly being explored, partially because of Haskell's dominance.

you can at least use a different prelude

I will have to look into that.

You always write executables at the end

This is not true. You will very likely need some kind of executable at some point to run your program. What you write is a solution to a problem. With FP, you don't need to know what the underlying architecture is, only how the functions are composed from smaller functions.

E.g. in big data applications, you might map a pure function f over a data source and split the computations over many nodes. This can be expressed simply as fmap f stream. Done. Let the compiler figure out how to turn that into executables, config files and deployment actions.

allows you to treat your algorithm as data structure you traverse (which is pretty cool imo)

True, and agreed. There are certainly upsides to non-strictness, which is why it became popular in the 80's in the first place. For the flagship of FP, I think it's a bad quality.
OTOH, maybe it's possible to turn non-strict code into strict code at compile time.

without laziness, some normally trivial identities do not hold

Interesting, do you have more info about this?

the bottom

I'm not really concerned with the bottom. While I'm in favor of fully functional programming, I don't think it's necessary. I'm not really sure what you're commenting on though.

for beginners they don't matter

Sort-of. If you're programming as a learning exercise it's fine. If you want to make something "real", you will likely need libraries, which are often made by more experienced devs. So for real-world development it has a bit of a wall in its learning curve.

When you come across a function with a polymorphic type with 7 instance requirements... I can understand optimization aspect of it but damn...

Collapse
 
jvanbruegge profile image
Jan van Brügge

I will have to look into that.

Just put NoImplicitPrelude into your .cabal file or put {-# LANGUAGE NoImplicitPrelude #-} at the top of ever file. I use Protolude for example: stephendiehl.com/posts/protolude.html

Interesting, do you have more info about this?

For example this: head . fmap f = f . head. If f bottoms on the second element in the list, the left will bottom and the right not. In a lazy language both won't.

I don't think it's necessary

Bottom is just the name for crashes (which is different than errors), ie non-recoverable, like panic!() in Rust. Strict languages don't need to bother, because a crash will just instantly crash the program. In a lazy language this is not the case, so you need a name to talk about this behavior.

Thread Thread
 
drbearhands profile image
DrBearhands

Ah, sorry, I meant "fully functional programming" isn't necessary, not bottom :-)