Konrad Hinsen
08/25/2023, 7:10 AMwtaysom
08/26/2023, 4:54 AMI would describe good Haskell code as ābrittleā, and I mean that as a compliment. People tend to casually use ābrittleā to mean āprone to breakageā, but in materials science what ābrittleā means is that something breaks without bending: when a brittle material reaches the limits of its strength, it fractures instead of deforming. Haskell is a language where abstractions do not ābendā (or permit invalid programs) but rather ābreakā (fail to compile) in the face of problems.And another:
I once heard it said that Haskell lets you work with functions the way Perl lets you work with strings. Lots of Haskell idioms, like monads, are perfectly expressible in other languages: Haskell just makes them feel natural, while writing a monad in many other languages feels like you have to do lots of busy-work.I wish the critique of Haskell was as good as the love expressed for it. For my part, I just find that most attempts write Haskell programs ends up down theoretical rabbit holes. Here's a tiny, silly example. For illustration purposes, I wanted to write
take 25 (map (^2) [0..])
as:
do
i <- [0..]
let ii = i * i
guard (i < 25)
return ii
This is, of course, bad because it loops after producing the 25 squares. You keep pulling off `i`s and keep fining that they are not longer less than 25. It would be "neat" if we could replace guard
with some sort of until
. But what sort? Could get lost for hours.Konrad Hinsen
08/26/2023, 6:04 PM