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 2015 Publication 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.
[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.
[3]
Pascal Costanza and Robert Hirschfeld. Language constructs for context-oriented programming: an overview of ContextL. In DLS '05, pages 1--10, 2005.
[4]
Pierpaolo Degano, Gian Luigi Ferrari, Letterio Galletta, and Gianluca Mezzetti. Typing context-dependent behavioural variation. In PLACES 2012, pages 28--33, 2012.
[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.
[6]
Ronald Garcia, Éric Tanter, Roger Wolff, and Jonathan Aldrich. Foundations of typestate-oriented programming. TOPLAS, 36(4):12:1--12:44, 2014.
[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.
[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.
[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.
[10]
Robert Hirschfeld, Pascal Costanza, and Oscar Nierstrasz. Context-oriented programming. Journal of Object Technology, 7(3):125--151, 2008.
[11]
Robert Hirschfeld, Atsushi Igarashi, and Hidehiko Masuhara. ContextFJ: a minimal core calculus for context-oriented programming. In FOAL '11, pages 19--23, 2011.
[12]
Atsushi Igarashi, Robert Hirschfeld, and Hidehiko Masuhara. A type system for dynamic layer composition. In FOOL 2012, pages 13--24, 2012.
[13]
Oleg Kiselyov and Chung-chieh Shan. Lightweight monadic regions. In Haskell 2008, pages 1--12, 2008.
[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.
[15]
Simon Marlow. Parallel and Concurrent Programming in Haskell. O'Reilly Media, 2013.
[16]
Chris Okasaki. Simple and efficient purely functional queues and deques. Journal of Functional Programming, 5(4):583--592, 1995.
[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.
[18]
Guido Salvaneschi, Carlo Ghezzi, and Matteo Pradella. ContextErlang: Introducing context-oriented programming in the actor model. In AOSD'12, pages 191--202, 2012.
[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.
[20]
Martin Sulzmann and Meng Wang. Aspect-oriented programming with type classes. In FOAL '07, pages 65--74, 2007.
[21]
Martin von Löwis, Marcus Denker, and Oscar Nierstrasz. Context-oriented programming: Beyond layers. In ICDL '07, pages 143--156, 2007.
[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.

Cited By

View all
  • (2017)A Layer-based Approach to Hierarchical Dynamically-scoped Open ClassesJournal of Information Processing10.2197/ipsjjip.25.29625(296-307)Online publication date: 2017

Index Terms

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

    Recommendations

    Comments

    Information & Contributors

    Information

    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
    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]

    Sponsors

    In-Cooperation

    • CTU: Czech Technical University in Prague
    • AITO: Assoc Internationale por les Technologies Objects

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 04 July 2015

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Context-oriented programming
    2. Haskell
    3. layer-introduced base functions
    4. type safety

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    ECOOP '15

    Acceptance Rates

    Overall Acceptance Rate 17 of 25 submissions, 68%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)1
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 07 Mar 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2017)A Layer-based Approach to Hierarchical Dynamically-scoped Open ClassesJournal of Information Processing10.2197/ipsjjip.25.29625(296-307)Online publication date: 2017

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media