Remix.run Logo
gylterud 4 days ago

I have found that Haskell has two good things going for it when it comes to LLM code generation. Both have to do with correctness.

The expressive type system catches a lot of mistakes, and the fact that they are compile errors which can be fed right into the LLM again means that incorrect code is caught early.

The second is property based testing. With it I have had the LLM generate amazingly efficient, correct code, by iteratively making it more and more efficient – running quickcheck on each pass. The LLM is not super good at writing the tests, but if you add some yourself, you quickly root out any mistakes in the generated code.

akoboldfrying 4 days ago | parent [-]

Property-based testing is available in other languages. E.g., JS has fast-check, inspired by quickcheck.

gylterud 4 days ago | parent [-]

The way code is written in Haskell, small laser focused functions and clearly defined and mockable side effects, lends itself very well to property based testing.

This might not be impossible to achieve in other languages, but I haven’t seen it used as prevailently in other languages.