Abstract
This paper presents Modular Reifiable Matching (MRM): a new approach to two level types using a fixpoint of list-of-functors representation. MRM allows the modular definition of datatypes and functions by pattern matching, using a style similar to the widely popular Datatypes a la Carte (DTC) approach. However, unlike DTC, MRM uses a fixpoint of list-of-functors approach to two-level types. This approach has advantages that help with various aspects of extensibility, modularity and reuse. Firstly, modular pattern matching definitions are collected using a list of matches that is fully reifiable. This allows for extensible pattern matching definitions to be easily reused/inherited, and particular matches to be overridden. Such flexibility is used, among other things, to implement extensible generic traversals. Secondly, the subtyping relation between lists of functors is quite simple, does not require backtracking, and is easy to model in languages like Haskell. MRM is implemented as a Haskell library, and its use and applicability are illustrated through various examples in the paper.
- K. Y. Ahn and T. Sheard. Shared subtypes: subtyping recursive parametrized algebraic data types. In Symposium on Haskell, pages 75–86, 2008. Google Scholar
Digital Library
- E. Axelsson. A generic abstract syntax model for embedded languages. In ICFP ’12, pages 323–334. ACM, 2012. Google Scholar
Digital Library
- P. Bahr. Composing and decomposing data types: a closed type families implementation of data types à la carte. In WGP ’14, pages 71–82. ACM, 2014. Google Scholar
Digital Library
- P. Bahr and T. Hvitved. Compositional data types. In Workshop on Generic Programming, WGP ’11, pages 83–94, 2011. Google Scholar
Digital Library
- E. Brady. Programming and reasoning with algebraic effects and dependent types. In ICFP ’13, pages 133–144. ACM, 2013. Google Scholar
Digital Library
- B. Bringert and A. Ranta. A pattern for almost compositional functions. In ICFP ’06, pages 216–226. ACM, 2006. Google Scholar
Digital Library
- J. Cheney. Scrap your nameplate. In ICFP ’05, 2005.Google Scholar
Digital Library
- B. C. d. S. Oliveira. Modular visitor components: A practical solution to the expression families problem. In ECOOP ’09, July 2009. Google Scholar
Digital Library
- B. Delaware, B. C. d. S. Oliveira, and T. Schrijvers. Meta-theory à la carte. In POPL ’13, 2013.Google Scholar
Digital Library
- R. A. Eisenberg, D. Vytiniotis, S. Peyton Jones, and S. Weirich. Closed type families with overlapping equations. In POPL ’14, 2014. Google Scholar
Digital Library
- M. Erwig and D. Ren. Monadification of functional programs. Science of Computer Programming, 52(1-3):101–129, 2004. Google Scholar
Digital Library
- J. Garrigue. Programming with polymorphic variants. ACM SIGPLAN Workshop on ML, 1998.Google Scholar
- M. Hyland, G. Plotkin, and J. Power. Combining effects: sum and tensor. Theoretical Computer Science, 357(1-3):70–99, 2006. Google Scholar
Digital Library
- O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. In Symposium on Haskell, pages 59–70. ACM, 2013. Google Scholar
Digital Library
- R. Lämmel and S. Peyton Jones. Scrap your boilerplate: a practical approach to generic programming. In TLDI ’03, pages 26–37. ACM, 2003. Google Scholar
Digital Library
- R. Lämmel and S. Peyton Jones. Scrap your boilerplate: A practical design pattern for generic programming. In TLDI’03, 2003.Google Scholar
Digital Library
- R. Lämmel and S. Peyton Jones. Scrap more boilerplate: Reflection, zips, and generalised casts. In ICFP ’04, 2004.Google Scholar
Digital Library
- R. Lämmel and S. Peyton Jones. Scrap your boilerplate with class: Extensible generic functions. In ICFP ’05, pages 204–215. ACM, 2005. Google Scholar
Digital Library
- R. Lämmel, J. Visser, and J. Kort. Dealing with large bananas. In WGP ’00, pages 46–59, 2000. Technical Report, Universiteit Utrecht.Google Scholar
- G. Malcolm. Algebraic Data Types and Program Transformation. PhD thesis, Groningen University, The Netherlands, 1990.Google Scholar
- L. Meertens. Paramorphisms. Formal Aspects of Computing, 4:413– 424, 1992.Google Scholar
Digital Library
- T. Millstein, C. Bleckner, and C. Chambers. Modular typechecking for hierarchically extensible datatypes and functions. ACM Trans. Program. Lang. Syst., 26(5), Sept. 2004. Google Scholar
Digital Library
- J. G. Morris and M. P. Jones. Instance chains: Type class programming without overlapping instances. In ICFP ’10, 2010. Google Scholar
Digital Library
- G. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP ’09, pages 80–94. Springer-Verlag, 2009. Google Scholar
Digital Library
- M. Rhiger. Type-safe pattern combinators. Journal of Functional Programming, 19:145–156, 2009. Google Scholar
Digital Library
- T. Sheard and E. Pasalic. Two-level types and parameterized modules. Journal of Functional Programming, 14(5):547–587, September 2004. Google Scholar
Digital Library
- W. Swierstra. Data types à la carte. Journal of Functional Programming, 18(4):423–436, July 2008. Google Scholar
Digital Library
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL ’89, pages 60–76. ACM, 1989. Google Scholar
Digital Library
- S. Weirich, B. A. Yorgey, and T. Sheard. Binders unbound. In ICFP ’11, 2011. Google Scholar
Digital Library
- N. Wu, T. Schrijvers, and R. Hinze. Effect handlers in scope. In Symposium on Haskell, pages 1–12. ACM, 2014. Google Scholar
Digital Library
- B. A. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalh˜aes. Giving haskell a promotion. In Workshop on Types in Language Design and Implementation, TLDI ’12, 2012. Google Scholar
Digital Library
Index Terms
Modular reifiable matching: a list-of-functors approach to two-level types
Recommendations
Modular reifiable matching: a list-of-functors approach to two-level types
Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on HaskellThis paper presents Modular Reifiable Matching (MRM): a new approach to two level types using a fixpoint of list-of-functors representation. MRM allows the modular definition of datatypes and functions by pattern matching, using a style similar to the ...
Type-level programming with match types
Type-level programming is becoming more and more popular in the realm of functional programming. However, the combination of type-level programming and subtyping remains largely unexplored in practical programming languages. This paper presents match ...
Variant parametric types: A flexible subtyping scheme for generics
We develop the mechanism of variant parametric types as a means to enhance synergy between parametric and inclusion polymorphism in object-oriented programming languages. Variant parametric types are used to control both the subtyping between different ...






Comments