skip to main content
research-article

Modular reifiable matching: a list-of-functors approach to two-level types

Published:30 August 2015Publication History
Skip Abstract Section

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.

References

  1. K. Y. Ahn and T. Sheard. Shared subtypes: subtyping recursive parametrized algebraic data types. In Symposium on Haskell, pages 75–86, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. E. Axelsson. A generic abstract syntax model for embedded languages. In ICFP ’12, pages 323–334. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. P. Bahr and T. Hvitved. Compositional data types. In Workshop on Generic Programming, WGP ’11, pages 83–94, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. E. Brady. Programming and reasoning with algebraic effects and dependent types. In ICFP ’13, pages 133–144. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. B. Bringert and A. Ranta. A pattern for almost compositional functions. In ICFP ’06, pages 216–226. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. Cheney. Scrap your nameplate. In ICFP ’05, 2005.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. B. C. d. S. Oliveira. Modular visitor components: A practical solution to the expression families problem. In ECOOP ’09, July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. B. Delaware, B. C. d. S. Oliveira, and T. Schrijvers. Meta-theory à la carte. In POPL ’13, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. A. Eisenberg, D. Vytiniotis, S. Peyton Jones, and S. Weirich. Closed type families with overlapping equations. In POPL ’14, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Erwig and D. Ren. Monadification of functional programs. Science of Computer Programming, 52(1-3):101–129, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Garrigue. Programming with polymorphic variants. ACM SIGPLAN Workshop on ML, 1998.Google ScholarGoogle Scholar
  13. M. Hyland, G. Plotkin, and J. Power. Combining effects: sum and tensor. Theoretical Computer Science, 357(1-3):70–99, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. In Symposium on Haskell, pages 59–70. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Lämmel and S. Peyton Jones. Scrap your boilerplate: A practical design pattern for generic programming. In TLDI’03, 2003.Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. R. Lämmel and S. Peyton Jones. Scrap more boilerplate: Reflection, zips, and generalised casts. In ICFP ’04, 2004.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Lämmel and S. Peyton Jones. Scrap your boilerplate with class: Extensible generic functions. In ICFP ’05, pages 204–215. ACM, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Lämmel, J. Visser, and J. Kort. Dealing with large bananas. In WGP ’00, pages 46–59, 2000. Technical Report, Universiteit Utrecht.Google ScholarGoogle Scholar
  20. G. Malcolm. Algebraic Data Types and Program Transformation. PhD thesis, Groningen University, The Netherlands, 1990.Google ScholarGoogle Scholar
  21. L. Meertens. Paramorphisms. Formal Aspects of Computing, 4:413– 424, 1992.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. J. G. Morris and M. P. Jones. Instance chains: Type class programming without overlapping instances. In ICFP ’10, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. G. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP ’09, pages 80–94. Springer-Verlag, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. Rhiger. Type-safe pattern combinators. Journal of Functional Programming, 19:145–156, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. T. Sheard and E. Pasalic. Two-level types and parameterized modules. Journal of Functional Programming, 14(5):547–587, September 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. W. Swierstra. Data types à la carte. Journal of Functional Programming, 18(4):423–436, July 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL ’89, pages 60–76. ACM, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Weirich, B. A. Yorgey, and T. Sheard. Binders unbound. In ICFP ’11, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. N. Wu, T. Schrijvers, and R. Hinze. Effect handlers in scope. In Symposium on Haskell, pages 1–12. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Modular reifiable matching: a list-of-functors approach to two-level types

    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

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 50, Issue 12
      Haskell '15
      December 2015
      212 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2887747
      Issue’s Table of Contents
      • cover image ACM Conferences
        Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell
        August 2015
        212 pages
        ISBN:9781450338080
        DOI:10.1145/2804302

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 30 August 2015

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!