The Glasgow Haskell Compiler (GHC) applied a dynamic programming approach inspired by RNA strand folding to improve its ApplicativeDo optimization algorithm as of May 2026 [1, 2].

ApplicativeDo is a GHC feature that allows programmers to write normal do notation while the compiler automatically detects independent computations. It substitutes the usual sequential binds (>>=), which enforce order, with Applicative operations (<*>), enabling parallel execution of independent expressions. This can reduce execution time by batching operations such as database calls into one round trip [1, 2].

However, GHC’s ApplicativeDo flag (-foptimal-applicative-do) remains disabled by default because its original underlying algorithm was too slow for practical use. Most GHC users continue to run programs without enabling the optimal setting, relying on the standard sequential execution that do notation desugars to [1, 2].

The improvement came from using the same dynamic programming technique biologists use to predict RNA folding. This algorithmic insight allowed the GHC team to tackle the complexity of deciding which parts of the code can run independently in parallel, speeding up the optimization process while preserving correctness [1, 2].

GHC first discussed these challenges and the potential solution in late May 2026, marking a significant step for the compiler’s ability to optimize Haskell code with ApplicativeDo [1, 2].

The next phase will focus on integrating this improved algorithm into a stable compiler release and encouraging adoption once its performance impact proves viable in real-world applications.