Development of an Assembly Language Interpreter Using Monad

모나드를 이용한 어셈블리 언어 인터프리터 개발

  • 변석우 (경성대학교 컴퓨터학부)
  • Received : 2010.01.25
  • Accepted : 2010.02.20
  • Published : 2010.05.15

Abstract

Monad in Haskell allows one to do imperative-style programming as well as pure functional programming. In this work, we characterize monadic abstraction and its programming technique by restructuring an assembly language interpreter coded in pure functional style into the one by the monadic style. Monad programming consists of two phases; the State monad is applied to a stack and a symbol table, and then a State Monad Transformer integrating these two monads is constructed. As a result, we can see that the program code by monad programming is much clearer and more intuitive than one written in the pure functional style.

하스켈의 모나드는 순수 함수형 프로그래밍뿐만 아니라 명령형 형태의 프로그래밍도 가능케 하고 있다. 본 연구에서는 순수 함수형 프로그래밍 방식으로 코딩된 어셈블리 언어 인터프리터 구현을 모나드 방식으로 재 구성함으로써 모나드 추상화와 프로그래밍 기법의 특성을 부각시킨다. 모나드 프로그래밍은 스택과 심볼 테이블에 상태 모나드를 적용하는 것과, 이 모나드들을 상태 모나드 트랜스포머를 이용하여 통합 구성하는 두 단계로 이루어진다. 결과적으로, 모나드 프로그래밍에 의한 코드는 순수 함수형 스타일의 코드보다 훨씬 더 간결하고 직관적임을 볼 수 있다.

Keywords

Acknowledgement

Supported by : 경성대학교

References

  1. Eugin Moggi. Computational lambda-calculus and monads. In IEEE Symposium on Logic in Computer Science, June 1989.
  2. Philip Wadler. Comprehending Monads. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming Languages, 1990.
  3. Graham Hutton. Programming in Haskell, Cambridge University Press, 2007.
  4. Simon Thompson. Haskell: The Craft of Functional Programming, Addison Wesley, 1999.
  5. Haskell Homepage. http://haskell.org.
  6. MTL (Monad Transformer Library). Control.Moad.
  7. Bryan O'Sullivan, Don Stewart, and John Goerzen, Real World Haskell, O'Reilly Media, 2008.
  8. Mark P. Jones. Functional programming with overloading and higher-order polymorphism. In Advanced Functional Programming, pp.97-136, 1995.
  9. Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools, Pearson Education, 1986.
  10. Sheng Liang, Paul Hudak, and Mark P. Jones, Monad transformers and modular interpreters. In POPL, pp.333-343, 1995.
  11. Sheng Liang, Modular Monadic Semantics and Compilation, PhD thesis, Yale University, 1997.
  12. David Espinosa, Building interpreters by transforming stratified monads, 1994.
  13. Guy L. Steele Jr, Building interpreters by composing monads, In POPL '94, January 1994.
  14. Paul Hudak, Modular Domain Specific Languages and Tools, Proceedings of Fifth International Conference on Software Reuse, IEEE Computer Society Press, 1998.