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

Am I the only one who never tried Haskell but who when reading discussion about it ends up thinking real-world (with GHC extensions) Haskell has way too much (sometimes historical) cruft? It really detracts me from it.


It's a thirty year-old language, it's bound to have cruft. However modern codebases tend to showcase a pretty efficient combination of language features, oftentimes optimised for productivity rather than research in lazy FP. Such codebases are https://github.com/flora-pm/flora-server or https://github.com/change-metrics/monocle


In practice it only detracts a little bit. You can enable GHC extensions project-wide and there are alternate standard libraries (preludes) that are more modern.

If you want a language that is very Haskell-like without the historical baggage or the laziness, PureScript is very good. It’s main compile target is JavaScript, so it’s built for different use cases.


Am I right in thinking that there are efforts to provide a better out-of-the-box experience, with some of that cruft dealt with for people who don't need the backwards compatibility? For myself, I found long prologues of extensions/options/whatever massively off-putting.


Sure, use

    {-# LANGUAGE GHC2024 #-}


Thanks. https://github.com/ghc-proposals/ghc-proposals/blob/master/p...

As I write, its links to ghc.gitlab.haskell.org are all broken.


Thanks for the report. I don't see any broken links to gitlab. I tried the first three and a random one. Could you point out the ones that are broken for you?


Works on mobile, not via my ISP (Virgin, UK). I guess it will resolve itself


Nice.


What cruft?


The standard library is atrocious, mainly I believe for historical reasons:

- map only works on Lists (one needs fmap for functors)

- head throwing exceptions instead of returning Maybe

- dependent types bolted on later: they're much nicer in Idris


> head throwing exceptions instead of returning Maybe

The choice is keep it is it is, or change it. Changing it would break vast amounts of existing code. Which option do you prefer?


I think this was given as an example of necessary-but-annoying cruft, not as a suggestion for change.


- map is easier on newcomers. Once you you understand functor, you'll remember to use fmap anyway. Also, I still use map for lists after 10+ years.

- I don't fully understand this, but do you mean that every `IO a` function would be better off being `IO (Maybe a)`?

- AFAIK, there are no dependent types in Haskell yet, but say that the type level programming you can do today is what you mean then you are already in quite advanced territory. Yeah, I guess it could be more polished.


I mean that `head` should be `List a -> Maybe a` rather than `List a -> a`. If you really really want an `a`, you should provide `NonEmptyList a` or something.


I agree! The current `head` should be renamed `unsafeHead` (or something), and the new `head` should have the type you wrote.



“atrocious” ? I don’t think that’s any Haskeller’s experience. We can point to a few things we’d like to be different for modern Haskell dev, which are slow to improve because of legacy etc, and a certain fragmentation across different packages, but relatively speaking, base and other core libs provide a wealth of high quality, well documented, principled utilities.


Exceptions n+k patterns Lazy IO




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

Search: