LLM-based Multi-Agent System for Intelligent Refactoring of Haskell Code

📅 2025-06-24
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
To address the challenges of manual, error-prone Haskell code refactoring—particularly the difficulty in simultaneously ensuring semantic correctness and performance optimization—this paper introduces the first LLM-driven multi-agent collaborative refactoring framework tailored for higher-order typed functional languages. The framework decomposes the refactoring task into four specialized agents: analysis, refactoring, verification, and debugging, integrating static analysis, type-aware semantic equivalence checking, and iterative debugging to guarantee structural safety and behavioral equivalence. End-to-end evaluation across multiple open-source Haskell projects demonstrates an average 11.03% reduction in code complexity, a 22.46% improvement in code quality, a 13.27% speedup in runtime performance, and up to 14.57% optimization in memory allocation. This work advances the trustworthy deployment of large language models in strongly typed functional programming environments.

Technology Category

Application Category

📝 Abstract
Refactoring is a constant activity in software development and maintenance. Scale and maintain software systems are based on code refactoring. However, this process is still labor intensive, as it requires programmers to analyze the codebases in detail to avoid introducing new defects. In this research, we put forward a large language model (LLM)-based multi-agent system to automate the refactoring process on Haskell code. The objective of this research is to evaluate the effect of LLM-based agents in performing structured and semantically accurate refactoring on Haskell code. Our proposed multi-agent system based on specialized agents with distinct roles, including code analysis, refactoring execution, verification, and debugging. To test the effectiveness and practical applicability of the multi-agent system, we conducted evaluations using different open-source Haskell codebases. The results of the experiments carried out showed that the proposed LLM-based multi-agent system could average 11.03% decreased complexity in code, an improvement of 22.46% in overall code quality, and increase performance efficiency by an average of 13.27%. Furthermore, memory allocation was optimized by up to 14.57%. These results highlight the ability of LLM-based multi-agent in managing refactoring tasks targeted toward functional programming paradigms. Our findings hint that LLM-based multi-agent systems integration into the refactoring of functional programming languages can enhance maintainability and support automated development workflows.
Problem

Research questions and friction points this paper is trying to address.

Automate Haskell code refactoring using LLM-based multi-agent system
Improve code quality and reduce complexity via automated refactoring
Enhance maintainability of functional programming languages with AI
Innovation

Methods, ideas, or system contributions that make the work stand out.

LLM-based multi-agent system for Haskell
Specialized agents handle distinct refactoring roles
Automated code complexity and quality improvement