• Title/Summary/Keyword: State Monad

Search Result 3, Processing Time 0.019 seconds

Development of an Assembly Language Interpreter Using Monad (모나드를 이용한 어셈블리 언어 인터프리터 개발)

  • Byun, Sug-Woo
    • Journal of KIISE:Software and Applications
    • /
    • v.37 no.5
    • /
    • pp.403-410
    • /
    • 2010
  • 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.

Feasibility Study Of Functional Programming In Scala Language By Implementing An Interpreter

  • Sugwoo, Byun
    • Journal of the Korea Society of Computer and Information
    • /
    • v.28 no.2
    • /
    • pp.111-119
    • /
    • 2023
  • In this paper, we investigate the feasibility of functional programming in the Scala language. The main issue is to what extent Scala is able to handle major properties of functional programming such as lambda expression, high-order functions, generic types, algebraic data types, and monads. For this purpose, we implement an interpreter of an imperative language. In this implementation, the same functional programming techniques are applied to both Haskell and Scala languages, and then these two versions of implementations are compared and analyzed. The abstract syntax tree of an imperative language is expressed as algebraic data types with generics and enum classes in Scala, and the state transition of imperative languages is implemented by using state monad. Extension and given, new features of Scala, are used as well.

Deterministic Parallelism for Symbolic Execution Programs based on a Name-Freshness Monad Library

  • Ahn, Ki Yung
    • Journal of the Korea Society of Computer and Information
    • /
    • v.26 no.2
    • /
    • pp.1-9
    • /
    • 2021
  • In this paper, we extend a generic library framework based on the state monad to exploit deterministic parallelism in a purely functional language Haskell and provide benchmarks for the extended features on a multicore machine. Although purely functional programs are known to be well-suited to exploit parallelism, unintended squential data dependencies could prohibit effective parallelism. Symbolic execution programs usually implement fresh name generation in order to prevent confusion between variables in different scope with the same name. Such implementations are often based on squential state management, working against parallelism. We provide reusable primitives to help developing parallel symbolic execution programs with unbound-genercis, a generic name-binding library for Haskell, avoiding sequential dependencies in fresh name generation. Our parallel extension does not modify the internal implementation of the unbound-generics library, having zero possibility of degrading existing serial implementations of symbolic execution based on unbound-genecrics. Therefore, our extension can be applied only to the parts of source code that need parallel speedup.