Table of Contents
Fetching ...

Distributed Approach to Haskell Based Applications Refactoring with LLMs Based Multi-Agent Systems

Shahbaz Siddeeq, Zeeshan Rasheed, Malik Abdul Sami, Mahade Hasan, Muhammad Waseem, Jussi Rasku, Mika Saari, Kai-Kristian Kemell, Pekka Abrahamsson

TL;DR

This paper tackles automated refactoring of Haskell codebases, a challenging domain due to immutability and monads. It proposes an LLM-based multi-agent system that distributes context analysis, refactoring, validation, and testing tasks across specialized agents. In evaluation on two codebases, the system achieves notable improvements including a McCabe Cyclomatic Complexity reduction $CC = E - N + 2P$, runtime reductions up to 50%, and memory reductions up to 41.73%, outperforming traditional rule-based tools. The work demonstrates scalable, automated refactoring for functional languages and provides an open-source platform for replication and extension.

Abstract

We present a large language models (LLMs) based multi-agent system to automate the refactoring of Haskell codebases. The multi-agent system consists of specialized agents performing tasks such as context analysis, refactoring, validation, and testing. Refactoring improvements are using metrics such as cyclomatic complexity, run-time, and memory allocation. Experimental evaluations conducted on Haskell codebases demonstrate improvements in code quality. Cyclomatic complexity was reduced by 13.64% and 47.06% in the respective codebases. Memory allocation improved by 4.17% and 41.73%, while runtime efficiency increased by up to 50%. These metrics highlight the systems ability to optimize Haskells functional paradigms while maintaining correctness and scalability. Results show reductions in complexity and performance enhancements across codebases. The integration of LLMs based multi-agent system enables precise task execution and inter-agent collaboration, addressing the challenges of refactoring in functional programming. This approach aims to address the challenges of refactoring functional programming languages through distributed and modular systems.

Distributed Approach to Haskell Based Applications Refactoring with LLMs Based Multi-Agent Systems

TL;DR

This paper tackles automated refactoring of Haskell codebases, a challenging domain due to immutability and monads. It proposes an LLM-based multi-agent system that distributes context analysis, refactoring, validation, and testing tasks across specialized agents. In evaluation on two codebases, the system achieves notable improvements including a McCabe Cyclomatic Complexity reduction , runtime reductions up to 50%, and memory reductions up to 41.73%, outperforming traditional rule-based tools. The work demonstrates scalable, automated refactoring for functional languages and provides an open-source platform for replication and extension.

Abstract

We present a large language models (LLMs) based multi-agent system to automate the refactoring of Haskell codebases. The multi-agent system consists of specialized agents performing tasks such as context analysis, refactoring, validation, and testing. Refactoring improvements are using metrics such as cyclomatic complexity, run-time, and memory allocation. Experimental evaluations conducted on Haskell codebases demonstrate improvements in code quality. Cyclomatic complexity was reduced by 13.64% and 47.06% in the respective codebases. Memory allocation improved by 4.17% and 41.73%, while runtime efficiency increased by up to 50%. These metrics highlight the systems ability to optimize Haskells functional paradigms while maintaining correctness and scalability. Results show reductions in complexity and performance enhancements across codebases. The integration of LLMs based multi-agent system enables precise task execution and inter-agent collaboration, addressing the challenges of refactoring in functional programming. This approach aims to address the challenges of refactoring functional programming languages through distributed and modular systems.

Paper Structure

This paper contains 22 sections, 6 figures, 2 tables.

Figures (6)

  • Figure 1: Example: Haskell language before and after refactoring.
  • Figure 2: Research Methodology
  • Figure 3: Cyclomatic Complexity Reduction for Codebase A and B
  • Figure 4: Runtime and Memory Usage for Codebase A and B (Pre- and Post-Refactoring)
  • Figure 5: Comparison of HLint Recommendations for Codebase A and B
  • ...and 1 more figures