Specifying and Controlling Agents in Haskell Martin Sulzmann and Edmund S. L. Lam School of Computing, National University of Singapore S16 Level 5, 3 Science Drive 2, Singapore 117543 {sulzmann,lamsoonl}@comp.nus.edu.sg Abstract. We present a domain-specific language embedded into Haskell to program software agents.We use monads to maintain a clear separa- tion among the different levels of reasonings, e.g. lower-level reasoning operations concerning the agent’s beliefs and actions versus higher-level operations dealing with the agent’s goals and plans. This serves as a basis for composable high level abstractions supporting complex specification and control regimes in a concise and reusable manner. 1 Introduction Software agents are entities that carry out complex tasks pro-actively in a dy- namically changing environment. They have been successfully applied in numer- ous areas such as air-traffic controlling, tele-communications, space exploration and business processes. While there exist well-established frameworks to specify agents, there is no general consense how to implement them in todays general- purpose programming languages. Hence, there is often a significant gap between agent’s specification and the actual implementation. In this paper, we aim to close this gap by designing an agent-oriented lan- guage embedded into Haskell. The key idea of our approach is to maintain a clear distinction between low-level and high-level reasoning operations. Low-level op- erations involve the agent’s beliefs and actions whereas high-level operations involve the agent’s goals and plans. Each level of reasoning (computation) is described by a monad [22, 16]. Thus, we can maintain a clear separation among the different levels of reasoning and support the modular development of more complex reasoning operations. Typical low-level reasoning operations involve non-monotonic updates. For instance, consider an agent moving a certain object from one to location to an- other. As we will see, linear logic [8] is the natural choice to model this type of rea- soning. In our implementation we employ Constraint Handling Rules (CHRs) [7], which are a executable specification of a fragment of linear logic [3], to specify the agent’s lower level reasoning. High-level reasoning operations deal with the agent’s goals and plans. For example, consider the goal of moving an object to a designated location. A plan is a series of low-level actions to achieve a goal. Finding and implementing the plan is the programmer’s task. However, we can assist the programmer, by introducing sophisticated control-structures such as back-tracking which are implemented on top of the low-level operations.