Comment by kccqzy
9 hours ago
I noticed that AI likes to overuse foldl' and foldr (especially foldr) including analogous versions on Maps, even when there are simpler and more straightforward ways to achieve the same thing.
When AI writes foldr with a complicated accumulation function, I’d prompt AI to define a custom monoidal structure and then use foldMap. Then the reader doesn’t have to think about the asymmetric accumulation function and instead think about the mapping operation and the associative combine function separately. Factoring out the two jobs of the accumulation function is a great trick to improve readability: excellent tradeoff if the human is mostly reading the code.
[flagged]
The advantage of Haskell is higher quality code with fewer bugs even when you write fewer unit tests. The advantage is the same whether humans write the code or AI writes it.
This might not be noticeable if you only write short programs: if the human can put the entire program in the head or if the AI can keep the whole thing in the context window. It matters much more when the program gets bigger.
Fewer bugs is such a wild claim. Especially since study after study has shown that to be wishful thinking. Haskell apps have just as many bugs in general as anything else.
1 reply →
In my experience, AI does really well with a good type system. It tries something, if it doesn't compile, looks at the message, fixes, etc etc.
The compiler itself acts as a steering function for the AI. I've also had this experience with Rust.
my haskell is still natty