News for hackers. Stuff that matters.
Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @09:47AM (#26078078)
I'm enjoying the read. Having written a fair deal of Haskell, I'm really grateful for what leaning Haskell told me about programming at large. Snoyman has written amazing libs and acute articles, and I appreciate this series a lot.

My interest though are: what's next?

Can Haskell evolve? Can we move to a better standard lib? Here Snoyman has put forward a great effort by releasing his classy-prelude, but iirc he also stopped using it.

So what can be done? Could we come up with a new Haskell-spec version that fixes some of these, flips some pragmas to be on-by-default? I can imagine that laziness is not going out, it too much at the heart of the language: or am I just assuming that? But besides laziness there is a lot to fix by just setting a new standard. It will help newcomers, an eventually even old codebases may make the jump.

Some part of this article talks about partial functions. To what extend can we do without? Can we build a checker [1] for that and simply disallow it?

1: https://stackoverflow.com/questions/42151927/what-is-haskell...

Re:Haskell: The Bad Parts, part 2 (2020) by massysett on Tuesday February 09, 2021 @10:32AM (#26078597)
Laziness - or more precisely, non-strictness - is the essence of Haskell. Haskell was created because there were a bunch of non-strict languages out there, and folks saw a need for one non-strict language to rule them all.

Often a defining feature of Haskell is thought to be its purity. Purity arose from non-strictness. Monadic IO arose from non-strictness (other solutions to IO were also tried.)

This is best discussed in a paper: https://www.microsoft.com/en-us/research/wp-content/uploads/...

I guess you could make Haskell strict by default...but why? It wouldn't be Haskell anymore. Non-strictness is the defining element of the language. In my view a strict-by-default Haskell is...something else. Maybe it's better for certain things. Maybe it takes things to the next level. But it isn't Haskell. Don't call it that.

Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @12:15PM (#26080016)
I understand the historic context of laziness, and what it "brought" or "taught" us. But is it really that important now, or moving forward? I side with Snoyman in the "strict by default would probably be better".

Sure it's no longer Haskell then. But could there not be a language like Haskell leveraging strict by default? Possibly even on the GHC?

Re:Haskell: The Bad Parts, part 2 (2020) by PhineasRex on Tuesday February 09, 2021 @06:36PM (#26084010)
Making Haskell strict-by-default would also break the rewrite engine which is the core of Haskell's high performance with functional combinators.

The whole haskell project is about allowing programmers to write code that is declarative without making concessions for performance. Laziness makes this possible because it abstracts out evaluation order and thus allows extreme optimization by the compiler

Re:Haskell: The Bad Parts, part 2 (2020) by rowanG077 on Thursday February 11, 2021 @03:37PM (#26106787)
I don't see how the rewrite engine would break if Haskell would be strict. Can you expand on that?
Re:Haskell: The Bad Parts, part 2 (2020) by pera on Tuesday February 09, 2021 @01:38PM (#26081021)
Idris for instance is strict "by default" but still supports laziness through the Lazy data type.
Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @02:23PM (#26081473)
Forgot about Idris.

Elm, PureScript, OCaml (Reason/ReScript) and F# did come to mind.

Re:Haskell: The Bad Parts, part 2 (2020) by cycloptic on Tuesday February 09, 2021 @12:28PM (#26080187)
Isn't that basically every other ML variant?
Re:Haskell: The Bad Parts, part 2 (2020) by wk_end on Tuesday February 09, 2021 @01:54PM (#26081184)
Not exactly. Syntax-aside, MLs in general: have better module systems than Haskell, no typeclasses, and aren’t pure.
Re:Haskell: The Bad Parts, part 2 (2020) by rtpg on Tuesday February 09, 2021 @10:34AM (#26078635)
I think what’s being proposed around “strict data fields by default” (or, an alternative or “some new concept that evokes strictness where it makes sense”) could let us continue to use Haskell and its laziness.

This isn’t really obvious to me but I think you could build a mixed reality without splitting a community up.

Re:Haskell: The Bad Parts, part 2 (2020) by mst on Tuesday February 09, 2021 @11:32AM (#26079424)
"strict-by-default" isn't really the proposal here.

Only "some things' laziness is more a footgun than a feature, maybe we should consider fixing those".

The foldl/sum/product example in part one is maybe clearer about that.

Re:Haskell: The Bad Parts, part 2 (2020) by lmm on Tuesday February 09, 2021 @10:17PM (#26085393)
But once you have purity you don't need strictness - Idris takes that approach.

Implicit, pervasive laziness makes performance non-compositional and more or less impossible to reason about. AIUI the largest industrial deployment of Haskell uses a strict variant for this reason.

Re:Haskell: The Bad Parts, part 2 (2020) by willtim on Tuesday February 09, 2021 @11:12AM (#26079186)
IMHO Haskell is missing three features that would really improve programming in the large:

1) better structural types. For example, polymorphic extensible records and variants. These could even be the basis for all algebraic data types. Current encodings have poor syntax and poor type inference (due to non-injective type families). The need to make all records nominal types really gets in the way when dealing with structured data. Python is the main competitor here; and so we could also just use strings and maps, but we can do better.

2) a better module system. Even Miranda had a better module system than Haskell. OOP has first-class modules.

3) a better commitment to backwards compatibility. There have been controversial and breaking changes to Haskell's standard libraries that have done more harm than good. This has likely damaged industrial adoption of Haskell. For example, my employer, a prominent Haskell sponsor, is stuck on a 7-year old version.

Unfortunately the above problems are difficult to retrofit for and so I think a new language may ultimately be needed.

Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Tuesday February 09, 2021 @12:06PM (#26079882)
You realize 3 would make 1 and 2 harder or less valuable? And 3 would have also prevented a gazillion 1s and 2s from being still with us?

I think breaking changes are highly underratted and people only shy away from them because the tooling expectations in all languages are so rock bottom.

Re:Haskell: The Bad Parts, part 2 (2020) by willtim on Tuesday February 09, 2021 @12:25PM (#26080161)
> You realize 3 would make 1 and 2 harder or less valuable?

Yes that is why I think (1) and (2) need a new language.

> And 3 would have also prevented a gazillion 1s and 2s from being still with us?

I disagree. Most new features have been implemented as extensions that must be enabled with language pragmas. This is not the same thing as large breaking changes in the standard libraries.

Re:Haskell: The Bad Parts, part 2 (2020) by IngoBlechschmid on Tuesday February 09, 2021 @04:39PM (#26082686)
Isn't constructing a new language the ultimate breaking change :-)
Re:Haskell: The Bad Parts, part 2 (2020) by eyelidlessness on Tuesday February 09, 2021 @10:13PM (#26085367)
I don’t have a dog in this fight other than interest in ML-family langs generally and Haskell as a pervasive interest everywhere I go outside of Haskell. But...

No not really, if your language is intentionally designed to be a foundation for other languages. So many lisps are trivially host languages for other languages at their core. Even JS is at this point, with the widespread use of Babel and various bundlers. Those languages themselves are seldom very different underneath that.

Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Wednesday February 10, 2021 @01:16PM (#26092791)
Making a "language laboratory" for typed languages, (as opposed FFI with lowest common denominators like C or so-and-so untyped, garbage-collected language) is an open problem. I think it can be solved, but until it is, it's wishful thinking to pretend a multitude of similar languages doesn't result in tragic fragmentation of a small community.
Re:Haskell: The Bad Parts, part 2 (2020) by eyelidlessness on Wednesday February 10, 2021 @10:54PM (#26098082)
TypeScript seems to be doing alright? Maybe there’s something I’m missing but TS is basically a type checker on top of everything JS compiles to, including the whole Babel universe and compiler transforms that support macros and arbitrary AST manipulation. Even its standard config offers a multitude of similar languages.
Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Thursday February 11, 2021 @12:53PM (#26104802)
Having a type language on top of an untyped one is fine (except for perf). It's having multiple typed ones that compose well and aren't just reskins of the same basic type theory that's the harder part.
Re:Haskell: The Bad Parts, part 2 (2020) by matheusmoreira on Wednesday February 10, 2021 @08:42AM (#26088868)
Isn't any breaking change the same as creating a new language?

There will be two similar yet different languages in use until everyone migrates to the new version. This process could happen quickly or not at all.

Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Wednesday February 10, 2021 @01:09PM (#26092710)
Yes, but there is much more likely to be tooling to migrate in the same name / same community case.
Re:Haskell: The Bad Parts, part 2 (2020) by willtim on Wednesday February 10, 2021 @02:34AM (#26086511)
Only if Haskell stops being maintained, which I very much doubt would happen. Therefore no one is forced into the change.
Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Wednesday February 10, 2021 @01:13PM (#26092757)
No one is forced to upgrade to a newer version either.

Now, perhaps the problem in your eyes is the old version isn't being maintained. But I see the opposite: maintaining two versions indefinitely is the problem. The Haskell community is not infinitely big, nor growing fast enough, that if e.g. 1/2 went to Idris and 1/2 stayed, it wouldn't be catastrophic.

Making the changes we need to make, and then making it as easy as possible for everyone to migrate, I think is the best way.

Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Tuesday February 09, 2021 @06:44PM (#26084080)
I wish more people would realize this!
Re:Haskell: The Bad Parts, part 2 (2020) by kthielen on Wednesday February 10, 2021 @09:45AM (#26089763)
People have made languages to address these issues (including me), and even put them in critical systems, but it is very difficult to get people to sign on to a new language.
Re:Haskell: The Bad Parts, part 2 (2020) by tikhonj on Tuesday February 09, 2021 @06:14PM (#26083801)
The practical problem is that backwards compatibility and making real improvements to the language are fundamentally at odds. There's just no way around it. If you can't break compatibility, you can't make meaningful improvements except for adding features and capabilities—and most of the problems in this article are about things that need to be taken away, not things that need to be added!
Re:Haskell: The Bad Parts, part 2 (2020) by willtim on Wednesday February 10, 2021 @11:43AM (#26091482)
I was responding to "Can Haskell evolve?", I was trying to say "I think it can, but I would prefer it to evolve in a new language". The standard library is riddled with partial functions, like head and tail. We should not take them away and break thousands of projects, research papers, books and blog articles.
Re:Haskell: The Bad Parts, part 2 (2020) by tome on Wednesday February 10, 2021 @12:12PM (#26091912)
> We should not take them away and break thousands of projects

How about the middle ground of marking them as deprecated and not to be used in new code?

Re:Haskell: The Bad Parts, part 2 (2020) by dllthomas on Monday February 22, 2021 @04:26AM (#26222435)
And I mean, they're perfectly suitable for futzing around in ghci. I think we need different preludes for different contexts.
Re:Haskell: The Bad Parts, part 2 (2020) by willtim on Wednesday February 10, 2021 @12:51PM (#26092447)
Yes, deprecation is fine, as long as they are not removed.
Re:Haskell: The Bad Parts, part 2 (2020) by mumblemumble on Tuesday February 09, 2021 @10:34AM (#26078629)
> Can Haskell evolve?

Should it? Haskell has already shown an impressive ability to evolve. Evolution is how it got where it is today. Language design analogues of the blood vessels being on the wrong side of the retina and all.

If the goal remains to have an effective research language with a more-or-less unsurpassed capacity for evolution and pushing the state of the art in interesting directions, I'd say Haskell is still great just as it is. If, on the other hand, the goal is to have a productive industrial programming language that encompasses all of Haskell's great ideas, but without quite so many troublesome language warts, evolutionary vestiges, or {-# LANGUAGE EverythingInterestingThatsHappenedOverThePastThirtyYears #-}, it might be better to make a clean break.

Re:Haskell: The Bad Parts, part 2 (2020) by agentultra on Tuesday February 09, 2021 @10:51AM (#26078875)
GHC is a production-ready compiler (for Haskell) suited for industry use. I work on a growing, healthy team and we ship an application written in Haskell several times a day. It has decent tooling, which is improving, and the language itself is what makes it possible to tolerate the pace of those developments.

Haskell isn't a pure "research-only" language. I realize people like to point out that it's original goal was research... however the nature of that research has changed over time. Take Galois' Crucible project where they used advanced dependent-types in order to write their security analysis tool [0]. They could have used research-grade dependently-typed languages that are much more expressive and easier to use... but they chose Haskell because they needed an industrial-grade compiler capable of producing fast code to run in a production setting. The kind of research being done in GHC and Haskell these days is bringing innovation and advancement in functional programming into industrial applications.

Every compiler is going to have warts. Especially with people using it and depending on it for industrial use. That's a good thing. You could be like Lean 4 which will make no promises of backwards compatibility or consideration for industrial users in the name of staying purely for research.

Although I agree that Haskell is impressive in its ability to evolve and grow! Linear types just landed in GHC 9.0.1 and many fine folks are improving the compiler to make way for dependent types. It's good stuff!

And to see languages like Java, C#, C++, and others pick up on the low-hanging fruit of FP languages is a sign that the paradigm is gaining popularity and adoption: ADTs, lamdbas, type inference, pattern matching... Maybe in 20-30 years will see these languages adopting higher-kinded types, rank-n types, GADTs, and more?

[0] https://www.researchgate.net/publication/334751646_Dependent...

Re:Haskell: The Bad Parts, part 2 (2020) by haskellandchill on Tuesday February 09, 2021 @11:00AM (#26079010)
Growing healthy Haskell team? Checks notes oh I already applied :)
Re:Haskell: The Bad Parts, part 2 (2020) by roflc0ptic on Tuesday February 09, 2021 @01:54PM (#26081192)
Have you tried Digital Asset?
Re:Haskell: The Bad Parts, part 2 (2020) by haskellandchill on Tuesday February 09, 2021 @02:10PM (#26081348)
Yes, general rule is if there’s a Haskell job I’ve at some point applied for it.
Re:Haskell: The Bad Parts, part 2 (2020) by lambda_obrien on Tuesday February 09, 2021 @03:12PM (#26081907)
I want to work in Haskell, do you have any other suggestions for companies?
Re:Haskell: The Bad Parts, part 2 (2020) by haskellandchill on Tuesday February 09, 2021 @03:56PM (#26082291)
Bitnomial, College Vine, Sentenai, Mercury, and Co-star are Haskell companies I've applied to recently. There's a different set if UK or EU is an option.
Re:Haskell: The Bad Parts, part 2 (2020) by giovannibonetti on Wednesday February 10, 2021 @06:30PM (#26096284)
What options do you know about in the EU and UK?
Re:Haskell: The Bad Parts, part 2 (2020) by roflc0ptic on Tuesday February 09, 2021 @04:14PM (#26082456)
IOHK, Lumi are two others
Re:Haskell: The Bad Parts, part 2 (2020) by lambda_obrien on Wednesday February 10, 2021 @02:59PM (#26093896)
Thanks!
Re:Haskell: The Bad Parts, part 2 (2020) by lambda_obrien on Wednesday February 10, 2021 @02:59PM (#26093894)
Thanks!
Re:Haskell: The Bad Parts, part 2 (2020) by lambda_obrien on Tuesday February 09, 2021 @03:11PM (#26081889)
Has anyone that you know of started using linear types for anything interesting yet?
Re:Haskell: The Bad Parts, part 2 (2020) by why_Mr_Anderson on Tuesday February 09, 2021 @02:51PM (#26081723)
Is there anything of any significance written in Haskell outside academia?
Re:Haskell: The Bad Parts, part 2 (2020) by centimeter on Tuesday February 09, 2021 @06:06PM (#26083712)
Several large financial firms have significant Haskell codebases, plenty of random cryptocurrency startups are Haskell based, some of the Google TPU chips are/were written in Haskell/Clash, Facebook has a big Haskell codebase, Starbucks and Target use it, there are several national security/defense firms extensively using Haskell, etc. etc.

Just because you don't see a bunch of blog posts like "We rewrote our <useless product> in <language du jour>!" doesn't mean it's not being used. In fact, more serious companies tend to lean less heavily on the developer social media publicity circuit.

Re:Haskell: The Bad Parts, part 2 (2020) by one-punch on Tuesday February 09, 2021 @11:21PM (#26085722)
> Starbucks and ... use it

I have heard of Haskell used in companies mentioned by other comments, but I am surprised, pleasantly, that Starbucks uses Haskell.

Do you have a pointer (job posting, blog post, etc.) to Starbucks using Haskell? It could help me push for using Haskell by my employer, for example.

Re:Haskell: The Bad Parts, part 2 (2020) by T-R on Tuesday February 09, 2021 @04:08PM (#26082407)
Re:Haskell: The Bad Parts, part 2 (2020) by agentultra on Tuesday February 09, 2021 @04:22PM (#26082528)
They also occasionally contribute libraries like Haxl [0] and HsThrift [1]

[0] https://hackage.haskell.org/package/haxl

[1] https://engineering.fb.com/2021/02/05/open-source/hsthrift/

Re:Haskell: The Bad Parts, part 2 (2020) by lalaithion on Tuesday February 09, 2021 @03:29PM (#26082062)
Re:Haskell: The Bad Parts, part 2 (2020) by mightybyte on Tuesday February 09, 2021 @06:01PM (#26083668)
Starbucks uses a system with a Haskell frontend and backend for generating their personalized offers. I have it on good authority that it's probably been responsible for more than a billion dollars in revenue lift for Starbucks.
Re:Haskell: The Bad Parts, part 2 (2020) by one-punch on Tuesday February 09, 2021 @11:13PM (#26085677)
This is new to me.

I have heard of Haskell used in companies mentioned by other comments, but I am surprised, pleasantly, that Starbucks uses Haskell.

Do you have a pointer (job posting, blog post, etc.) to Starbucks using Haskell? It could help me push for using Haskell by my employer, for example.

Re:Haskell: The Bad Parts, part 2 (2020) by mightybyte on Tuesday February 09, 2021 @11:44PM (#26085820)
Starbucks themselves didn't use Haskell. They used a system built by another company that used Haskell.
Re:Haskell: The Bad Parts, part 2 (2020) by dgellow on Tuesday February 09, 2021 @03:34PM (#26082099)
Depends your definition of "significance" but Cardano is written in Haskell, and its main smart contract language is also Haskell.

https://cardano.org/

Re:Haskell: The Bad Parts, part 2 (2020) by codebje on Wednesday February 10, 2021 @01:11AM (#26086146)
CircuitHub is apparently built with Haskell. It's the most polished PCB manufacturing quote system I've seen, but "significance" is relevant. (Plus I've never actually used their service, since it's not priced for hobbyist manufacture of a small number of boards).
Re:Haskell: The Bad Parts, part 2 (2020) by mumblemumble on Tuesday February 09, 2021 @03:12PM (#26081908)
Pandoc comes to mind.
Re:Haskell: The Bad Parts, part 2 (2020) by tome on Tuesday February 09, 2021 @02:53PM (#26081748)
It might help if you define "of significance".
Re:Haskell: The Bad Parts, part 2 (2020) by jcelerier on Tuesday February 09, 2021 @04:26PM (#26082570)
> Maybe in 20-30 years will see these languages adopting higher-kinded types, rank-n types, GADTs, and more?

it's possible to express those in C++ pretty much since templates exist.

Re:Haskell: The Bad Parts, part 2 (2020) by tikhonj on Tuesday February 09, 2021 @06:30PM (#26083959)
Haskell needs its own Elixir: a language different enough to fix fundamental problems but similar enough to inhabit the same world. I'm imagining a language with its own frontend and some of its own features that could still reuse GHC (maybe from Core down) and share libraries freely in both directions, while also able to address some fundamental issues without being constrained by backwards compatibility.

I personally love Haskell: I think it's in a great place as a language (even if it isn't wildly popular) and on a positive trajectory. But I definitely feel the same pain points Snoyman brings up, and maybe some others. (Template Haskell >.<) I don't see any way of fixing many of the biggest issues if we care about backwards-compatibility at all, and a language with 30 years of existing code can never get away from that. I also don't think te community could weather a Python 2 → 3 transformation (much less Perl 5 → 6). So the only path I see towards simultaneously keeping what's great about Haskell and improving all that isn't would be another language that can coexist simultaneously, just like Elixir and Erlang.

Re:Haskell: The Bad Parts, part 2 (2020) by Kototama on Tuesday February 09, 2021 @06:55PM (#26084171)
PureScript would almost fit :-). It would just need a modern Haskell backend but having a strict language built on a lazy-one is probably not the best idea :-).
Re:Haskell: The Bad Parts, part 2 (2020) by YawningAngel on Tuesday February 09, 2021 @07:09PM (#26084284)
You can avoid lazy behaviour entirely in Haskell if you want to, so your purescript to haskell compiler can just only generate contrived haskell code that doesn't exhibit laziness
Re:Haskell: The Bad Parts, part 2 (2020) by cies on Wednesday February 10, 2021 @03:33AM (#26086803)
Idris maybe? If Idris has easy interop with the Rust ecosystem, we'd have a great backend (and with wasmer possibly also fontend) option.
Re:Haskell: The Bad Parts, part 2 (2020) by Kototama on Thursday February 11, 2021 @06:06AM (#26100277)
I was also thinking as Rust as a backend for a FP language in the last day. I found some Ocaml binding for Rust. It would be interesting to see how it fits.
Re:Haskell: The Bad Parts, part 2 (2020) by lizmat on Monday February 15, 2021 @10:04AM (#26143349)
or like Perl and the Raku Programming Language https://raku.org :-)
Re:Haskell: The Bad Parts, part 2 (2020) by gizmo686 on Tuesday February 09, 2021 @10:12AM (#26078356)
GHC already supports strict-by-default

https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/stri...

Obviously making it the default would be backwards incompatible. But, as long as lazyness remains supported and simple to use on a per-case basis, it doesn't actually seem like that big of a change to me.

Also, the fact that GHC supports so many extensions actually gives a good path to updating the language. Since extension are enabled on a per-file basis, in most cases old libraries would just work with new-Haskell as long as the build system knows to build them in old-Haskell mode.

Re:Haskell: The Bad Parts, part 2 (2020) by nightski on Tuesday February 09, 2021 @10:22AM (#26078465)
I worked with Haskell for a few years and have a book on immutable data structures (Okasaki) in my book shelf here. From what I remember, with immutable data structures strict by default is actually a pretty bad default (please correct me if I remember wrong). I can only imagine this is one of the reasons Haskell is lazy by default (seriously, it's more than just that they wanted to try this crazy thing).

Just enabling strictness everywhere in Haskell isn't just inherently better. Laziness is actually quite good (and the OP even says this to an extent). It's more nuanced than it seems.

Re:Haskell: The Bad Parts, part 2 (2020) by lupire on Tuesday February 09, 2021 @11:11AM (#26079165)
Data should be strict, logic should be lazy. It's the programmer's job do use judgment to decide which parts of which data structures are data vs logic. One heuristic is that anything recursive should be lazy, and the rest strict

    (Tree = Leaf !Int | Node [Tree]))
and if you really need a lazy int in there, delay it yourself using partially applied functions.
Re:Haskell: The Bad Parts, part 2 (2020) by nightski on Tuesday February 09, 2021 @11:24AM (#26079343)
Yea, I agree with this and it's a good pattern in the case you know the type is "Int" or some other primitive. But Haskell thrives on type variables and data structures are usually defined generically making it more complicated.

From what I remember to get around this one would use a type class to define a data structure's operations, and then provide specific implementations of that data structure for specific strict data types. But that is more complicated than just having the compiler apply strictness everywhere.

Re:Haskell: The Bad Parts, part 2 (2020) by CountHackulus on Tuesday February 09, 2021 @06:44PM (#26084084)
Having just read that book, it's not that laziness is bad or good for data structure performance. It's mostly that you can't use a data structure designed for one paradigm with the other and expect the same performance characteristics. Laziness can make things faster (I think the CatenableQueue was a good example of this), but it can also make things slower (take your pick of examples).

In all I guess I'm not disagreeing with you at all, I just wanted to provide a bit more context and get some more use out of that book.

Re:Haskell: The Bad Parts, part 2 (2020) by gizmo686 on Tuesday February 09, 2021 @10:46AM (#26078791)
For small amounts of data, strictness is better then laziness. There is a simmilar lesson even in non-pure languages: copying small amounts of data is almost always faster than fancy scheme you want to do to avoid copying.

For large amounts of data in an immutable structure, laziness is pretty much essential. The theory behind strict-by-default is that most of the time, you are not dealing with large amounts of data; even if you have pointers to large data, or pointers to pointers of large data. Even though laziness is vital to a pure language, you only need to use it in a relatively small number of places.

Re:Haskell: The Bad Parts, part 2 (2020) by dwohnitmok on Tuesday February 09, 2021 @12:20PM (#26080092)
Wait why is laziness vital to large data structures? Even with strict functions on strict, but persistent functions, you almost never copy the entire data structure.

For example a strict function on a strict persistent list that swaps the head of the list doesn't have to copy the entire tail of the list.

The thing that laziness enables is short-circuiting, so e.g. a fold over the list can bail out early if necessary. But this is actually a minority of use cases for large data, since we often bound the size of data structures with something like a `take n` function for some integer n, which only processes n elements in a strict language.

Re:Haskell: The Bad Parts, part 2 (2020) by jrochkind1 on Tuesday February 09, 2021 @01:01PM (#26080581)
The OP addresses your question, saying he is not advocating for removing laziness, but does have some specific suggestions.

> I'm not advocating for removing laziness in Haskell. In fact I'm not really advocating for much of anything in this series. I'm just complaining, because I like complaining.

> But if I was to advocate some changes:

  * Deprecate partial functions
  * Introduce a naming scheme for partial functions to be more obvious
  * Introduce a compiler warning to note partial function use (with a pragma to turn off specific usages)
  * Warn by default on partial pattern matches
  * Advocate strict data fields by default
Re:Haskell: The Bad Parts, part 2 (2020) by colonwqbang on Tuesday February 09, 2021 @02:48PM (#26081702)
Change all partial functions from returning a to returning Maybe a. Then we rename the fromJust function into the $%&!# operator (name intended to suggest the exclamation made by the programmer when function fails).
Re:Haskell: The Bad Parts, part 2 (2020) by _ezkx on Tuesday February 09, 2021 @07:29PM (#26084415)
If StrictData were simply made the new default (with exceptions for lists and some other things in the standard lib), I bet very little code would break. It certainly wouldn't change the flavor of the language. I think it's a good idea.
Re:Haskell: The Bad Parts, part 2 (2020) by SkyMarshal on Tuesday February 09, 2021 @12:40PM (#26080347)
Keep Haskell as a research language imho, but perhaps create an industrial-oriented subset of the language, similar to Ada’s SPARK [1]. Make it strict if necessary, flip whatever pragmas support an industrial use case, etc., and create a separate brand but which still references Haskell.

[1]:https://en.wikipedia.org/wiki/SPARK_(programming_language)

Re:Haskell: The Bad Parts, part 2 (2020) by ivanbakel on Tuesday February 09, 2021 @10:10AM (#26078330)
>Some part of this article talks about partial functions. To what extend can we do without? Can we build a checker [1] for that and simply disallow it?

You don't need an advanced checker for partial functions - the link you use is discussing proving termination, but total vs partial functions just requires checking whether the function is defined for all arguments, which is easy and something that GHC can already do.

And to be honest, I'm not sure we can do without. Partial functions and `error` (or `undefined`) are necessary escape hatches for the programmer who knows something the compiler doesn't. Partial functions should probably not end up in any APIs (and definitely not in the Prelude), but they are still an important part of the language.

Only the introduction of dependent typing has the possibility of really eliminating partial functions for good.

Re:Haskell: The Bad Parts, part 2 (2020) by Ericson2314 on Tuesday February 09, 2021 @10:35AM (#26078648)
The issue is not "undefined" and "error" but accidental partiality.

`head` absolutely doesn't know something the compiler doesn't, because there is no guarantee the user is using it correctly!

The fact that https://doc.rust-lang.org/std/vec/struct.Vec.html#method.pop returns Option<T> really says it all. We're not trying to be perfect, we're just trying to be no worse than Rust, which shouldn't be a high bar at all.

I wrote https://github.com/ghc-proposals/ghc-proposals/pull/351 to address just these sorts of issues, and not the harder ones people confuse them with.

Re:Haskell: The Bad Parts, part 2 (2020) by ivanbakel on Tuesday February 09, 2021 @12:12PM (#26079963)
> The issue is not "undefined" and "error" but accidental partiality.

I don't understand what you mean by this.

>`head` absolutely doesn't know something the compiler doesn't, because there is no guarantee the user is using it correctly!

But the user can use `head` when they know that the list they are handling is non-empty (but then they can also opt for `Data.List.NonEmpty`). I never said the partial function itself carried any knowledge - only that it was a necessary escape hatch for cases where the programmer has the knowledge to use it correctly.

>We're not trying to be perfect, we're just trying to be no worse than Rust, which shouldn't be a high bar at all.

I'm not opposed to that - and I don't see why you would think that I am. I'm just arguing that, in response to the question made by the other commenter, we can't "do without" partial functions entirely. That doesn't mean I believe they belong everywhere, and certainly not in most APIs.

Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @12:29PM (#26080199)
> I don't understand what you mean by this.

I think that GP tries to say the escape hatches are not the problem. "error" and "undefined" are fine (we can check for undefined not being in production code, and errors, well, could be implemented as a "die" or "halt").

But head though... It should return a Maybe wrapped value! And as you say the other option is nonempty lists a.k.a. "(a, [a])".

> only that it was a necessary escape hatch for cases where the programmer has the knowledge to use it correctly.

Well the docs do not present head as an escape hatch out of Haskell iron type system! It's documented rather innocently [1] (search for head). Unlike unsafePerformIO[2] and the likes, which have whole epistols detailing their danger.

> I'm just arguing that, in response to the question made by the other commenter, we can't "do without" partial functions entirely.

Please consider escape hatches differently from basic stuff like head and you see we argue for the same end result. Head is plain bad, should be removed or annotated as the smelly thing it is. maybeHead and non-empty-collections are the way fwd there, would you agree?

1: http://hackage.haskell.org/package/base-4.3.1.0/docs/Prelude...

2: https://hackage.haskell.org/package/base-4.14.0.0/docs/Syste...

Re:Haskell: The Bad Parts, part 2 (2020) by ivanbakel on Wednesday February 10, 2021 @07:06AM (#26088140)
>Please consider escape hatches differently from basic stuff like head and you see we argue for the same end result. Head is plain bad, should be removed or annotated as the smelly thing it is. maybeHead and non-empty-collections are the way fwd there, would you agree?

I don't get what you're trying to say. I never said that head was good. The discussion about head is a sidetrack to the original question, which is "To what extend can we do without [partial functions]?", and to which my answer is "we can't do without". head is not a good example of a partial function, and its existence doesn't conflict with the idea that good partial functions are a necessary part of the language.

Re:Haskell: The Bad Parts, part 2 (2020) by 3np on Tuesday February 09, 2021 @10:32AM (#26078605)
Do you think there's any hope of Haskell community moving to Idris? It's years since I did either but I think Idris is just a Better Haskell without several of the issues brought up.
Re:Haskell: The Bad Parts, part 2 (2020) by lupire on Tuesday February 09, 2021 @11:12AM (#26079183)
For small programs, but not in general. Haskell has too many more language features and libraries.
Re:Haskell: The Bad Parts, part 2 (2020) by js8 on Tuesday February 09, 2021 @12:41PM (#26080364)
> Can we move to a better standard lib? Here Snoyman has put forward a great effort by releasing his classy-prelude, but iirc he also stopped using it.

He mentioned https://github.com/commercialhaskell/rio in the 1st article, it's interesting, I wasn't aware of it. (I am using classy-prelude but I might try it out.)

Re:Haskell: The Bad Parts, part 2 (2020) by cptwunderlich on Wednesday February 10, 2021 @03:25AM (#26086743)
FYI there was a proposal for a "Haskell 2021 Language" Extensions (similar to Haskell 98 and 2010), which was approved. This enables a bunch of extensions (and I guess will become default): https://github.com/ghc-proposals/ghc-proposals/blob/master/p...

That being said, while there are alternative preludes, I'm not sure how or when (or ever) the current prelude will be changed or replaced.

In terms of language evolution, the community seems to focus on further extensions of the Type System (linear types, quicklook impredicativity, dependent types), where I think there is a bigger need in better tooling. Of course, there too, lots of things are happening, like haskell-language-server, ghc-debug etc. etc. But still lots of work to do. Would be great if more people worked on modern tooling and improving GHC. And even better if more companies would fund that =)