skip to main content
10.1145/2786545.2786553acmconferencesArticle/Chapter ViewAbstractPublication PagesecoopConference Proceedingsconference-collections
research-article

Type-Safe Layer-Introduced Base Functions with Imperative Layer Activation

Published:04 July 2015Publication History

ABSTRACT

Layer-introduced base methods, which are the methods with new signatures in a layer and are added to a class, give layers more freedom to organize definitions of context-dependent behavior. However, we need to be careful so as not to call a layer-introduced base method while the layers that provide the method are inactive. Type-based solutions would help to avoid such a problematic situation, but existing ones are limited to context-oriented programming (COP) languages that have dynamically-scoped (i.e., the "with" based) layer activation. We propose a COP framework in Haskell that supports both imperative and dynamically-scoped layer activation mechanisms, as well as layer-introduced base functions. By representing a context as a stack of active layers in a type of a function in Haskell, type safety---including the guarantee of activation of a layer that provides a layer-introduced function---is checked by Haskell's type system. This paper shows how our framework encodes COP features in Haskell using a simple example.

References

  1. Tomoyuki Aotani, Tetsuo Kamina, and Hidehiko Masuhara. Context holders: realizing multiple layer activation mechanisms in a single context-oriented language. In FOAL 2014, pages 3--6, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Tomoyuki Aotani, Tetsuo Kamina, and Hidehiko Masuhara. Unifying multiple layer activation mechanisms using one event sequence. In COP'14, pages 2:1--2:6, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Pascal Costanza and Robert Hirschfeld. Language constructs for context-oriented programming: an overview of ContextL. In DLS '05, pages 1--10, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Pierpaolo Degano, Gian Luigi Ferrari, Letterio Galletta, and Gianluca Mezzetti. Typing context-dependent behavioural variation. In PLACES 2012, pages 28--33, 2012.Google ScholarGoogle Scholar
  5. Ismael Figueroa, Nicolas Tabareau, and Éric Tanter. Effective aspects: A typed monadic embedding of pointcuts and advice. Transactions on Aspect-Oriented Software Development, 11:145--192, 2013.Google ScholarGoogle Scholar
  6. Ronald Garcia, Éric Tanter, Roger Wolff, and Jonathan Aldrich. Foundations of typestate-oriented programming. TOPLAS, 36(4):12:1--12:44, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Sebastián González, Nicolás Cardozo, Kim Mens, Alfredo Cádiz, Jean-Christophe Libbrecht, and Julien Goffaux. Subjective-C: bringing context to mobile platform programming. In SLE'10, pages 246--265, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Sebastián González, Kim Mens, and Alfredo Cádiz. Context-oriented programming with the ambient object system. Journal of Universal Computer Science, 14(20):3307--3332, 2008.Google ScholarGoogle Scholar
  9. Tim Harris, Simon Marlow, Simon Peyton-Jones, and Maurice Herlihy. Composable memory transactions. In Proceedings of the Tenth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, PPoPP '05, pages 48--60, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Robert Hirschfeld, Pascal Costanza, and Oscar Nierstrasz. Context-oriented programming. Journal of Object Technology, 7(3):125--151, 2008.Google ScholarGoogle ScholarCross RefCross Ref
  11. Robert Hirschfeld, Atsushi Igarashi, and Hidehiko Masuhara. ContextFJ: a minimal core calculus for context-oriented programming. In FOAL '11, pages 19--23, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Atsushi Igarashi, Robert Hirschfeld, and Hidehiko Masuhara. A type system for dynamic layer composition. In FOOL 2012, pages 13--24, 2012.Google ScholarGoogle Scholar
  13. Oleg Kiselyov and Chung-chieh Shan. Lightweight monadic regions. In Haskell 2008, pages 1--12, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jens Lincke, Malte Appeltauer, Bastian Steinert, and Robert Hirschfeld. An open implementation for context-oriented layer composition in ContextJS. Science of Computer Programming, 76(12):1194--1209, December. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Simon Marlow. Parallel and Concurrent Programming in Haskell. O'Reilly Media, 2013.Google ScholarGoogle Scholar
  16. Chris Okasaki. Simple and efficient purely functional queues and deques. Journal of Functional Programming, 5(4):583--592, 1995.Google ScholarGoogle ScholarCross RefCross Ref
  17. Guido Salvaneschi, Carlo Ghezzi, and Matteo Pradella. Context-oriented programming: A software engineering perspective. Journal of Systems and Software, 85(8):1801--1817, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Guido Salvaneschi, Carlo Ghezzi, and Matteo Pradella. ContextErlang: Introducing context-oriented programming in the actor model. In AOSD'12, pages 191--202, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R E Strom and S Yemini. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering, 12(1):157--171, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Martin Sulzmann and Meng Wang. Aspect-oriented programming with type classes. In FOAL '07, pages 65--74, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Martin von Löwis, Marcus Denker, and Oscar Nierstrasz. Context-oriented programming: Beyond layers. In ICDL '07, pages 143--156, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon L. Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalães. Giving haskell a promotion. In TLDI 2012, pages 53--66, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Type-Safe Layer-Introduced Base Functions with Imperative Layer Activation

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      COP '15: Proceedings of the 7th ACM International Workshop on Context-Oriented Programming
      July 2015
      54 pages
      ISBN:9781450336543
      DOI:10.1145/2786545

      Copyright © 2015 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 4 July 2015

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
      • Research
      • Refereed limited

      Acceptance Rates

      Overall Acceptance Rate17of25submissions,68%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader