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.
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Pascal Costanza and Robert Hirschfeld. Language constructs for context-oriented programming: an overview of ContextL. In DLS '05, pages 1--10, 2005. Google ScholarDigital Library
- Pierpaolo Degano, Gian Luigi Ferrari, Letterio Galletta, and Gianluca Mezzetti. Typing context-dependent behavioural variation. In PLACES 2012, pages 28--33, 2012.Google Scholar
- 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 Scholar
- Ronald Garcia, Éric Tanter, Roger Wolff, and Jonathan Aldrich. Foundations of typestate-oriented programming. TOPLAS, 36(4):12:1--12:44, 2014. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- Robert Hirschfeld, Pascal Costanza, and Oscar Nierstrasz. Context-oriented programming. Journal of Object Technology, 7(3):125--151, 2008.Google ScholarCross Ref
- Robert Hirschfeld, Atsushi Igarashi, and Hidehiko Masuhara. ContextFJ: a minimal core calculus for context-oriented programming. In FOAL '11, pages 19--23, 2011. Google ScholarDigital Library
- Atsushi Igarashi, Robert Hirschfeld, and Hidehiko Masuhara. A type system for dynamic layer composition. In FOOL 2012, pages 13--24, 2012.Google Scholar
- Oleg Kiselyov and Chung-chieh Shan. Lightweight monadic regions. In Haskell 2008, pages 1--12, 2008. Google ScholarDigital Library
- 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 ScholarDigital Library
- Simon Marlow. Parallel and Concurrent Programming in Haskell. O'Reilly Media, 2013.Google Scholar
- Chris Okasaki. Simple and efficient purely functional queues and deques. Journal of Functional Programming, 5(4):583--592, 1995.Google ScholarCross Ref
- 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 ScholarDigital Library
- Guido Salvaneschi, Carlo Ghezzi, and Matteo Pradella. ContextErlang: Introducing context-oriented programming in the actor model. In AOSD'12, pages 191--202, 2012. Google ScholarDigital Library
- 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 ScholarDigital Library
- Martin Sulzmann and Meng Wang. Aspect-oriented programming with type classes. In FOAL '07, pages 65--74, 2007. Google ScholarDigital Library
- Martin von Löwis, Marcus Denker, and Oscar Nierstrasz. Context-oriented programming: Beyond layers. In ICDL '07, pages 143--156, 2007. Google ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Type-Safe Layer-Introduced Base Functions with Imperative Layer Activation
Recommendations
Generalized layer activation mechanism through contexts and subscribers
MODULARITY 2015: Proceedings of the 14th International Conference on ModularityContext-oriented programming (COP) languages modularize context-dependent behaviors in multiple classes into layers. These languages have layer activation mechanisms so that the behaviors in layers take effect on a particular unit of computation during ...
On-Demand Layer Activation for Type-Safe Deactivation
COP '14: Proceedings of 6th ACM International Workshop on Context-Oriented ProgrammingDynamic layer deactivation in context-oriented programming (COP) allows a layer to be dynamically disabled in the running application in a disciplined way. Deactivating a layer may lead to an error if there is another layer which has been activated but ...
Method safety mechanism for asynchronous layer deactivation
Context-oriented programming (COP) enhances the modularity of context-dependent behavior in context-aware systems, as it provides modules to implement context-dependent behavior (layers) and composes them dynamically in a disciplined manner (layer ...
Comments