Abstract
We present a novel typed language for extensible data types, generalizing and abstracting existing systems of row types and row polymorphism. Extensible data types are a powerful addition to traditional functional programming languages, capturing ideas from OOP-like record extension and polymorphism to modular compositional interpreters. We introduce row theories, a monoidal generalization of row types, giving a general account of record concatenation and projection (dually, variant injection and branching). We realize them via qualified types, abstracting the interpretation of records and variants over different row theories. Our approach naturally types terms untypable in other systems of extensible data types, while maintaining strong metatheoretic properties, such as coherence and principal types. Evidence for type qualifiers has computational content, determining the implementation of record and variant operations; we demonstrate this in giving a modular translation from our calculus, instantiated with various row theories, to polymorphic λ-calculus.
Supplemental Material
- P. Bahr. Composing and decomposing data types: a closed type families implementation of data types à la carte. In J. P. Magalhães and T. Rompf, editors, Proceedings of the 10th ACM SIGPLAN workshop on Generic programming, WGP 2014, Gothenburg, Sweden, August 31, 2014 , pages 71–82. ACM, 2014. Google Scholar
Digital Library
- B. Berthomieu and C. le Moniès de Sagazan. A calculus of tagged types, with applications to process languages. In Workshop on types for program analysis , Aarhus, 1995.Google Scholar
- M. Blume, U. A. Acar, and W. Chae. Extensible programming with first-class cases. In J. H. Reppy and J. L. Lawall, editors, Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006, Portland, Oregon, USA, September 16-21, 2006 , pages 239–250. ACM, 2006. Google Scholar
Digital Library
- G. Boisseau and J. Gibbons. What you needa know about Yoneda: profunctor optics and the Yoneda Lemma (Functional Pearl). PACMPL, 2(ICFP):84:1–84:27, 2018. Google Scholar
Digital Library
- A. Chlipala. Ur: statically-typed metaprogramming with type-level record computation. In B. G. Zorn and A. Aiken, editors, Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2010, Toronto, Ontario, Canada, June 5-10, 2010 , pages 122–133. ACM, 2010. Google Scholar
Digital Library
- J. Dunfield. Elaborating intersection and union types. In P. Thiemann and R. B. Findler, editors, ACM SIGPLAN International Conference on Functional Programming, ICFP’12, Copenhagen, Denmark, September 9-15, 2012 , pages 17–28. ACM, 2012. Google Scholar
Digital Library
- J. N. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, and A. Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst., 29(3):17, 2007. Google Scholar
Cross Ref
- J. Garrigue. Programming with polymorphic variants. In ML Workshop. ACM, 1998.Google Scholar
- B. R. Gaster and M. P. Jones. A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, University of Nottingham, 1996.Google Scholar
- R. Harper and B. Pierce. A record calculus based on symmetric concatenation. In Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages , POPL ’91, pages 131–142. ACM, 1991. Google Scholar
Digital Library
- D. Hillerström and S. Lindley. Liberating effects with rows and handlers. In [email protected], pages 15–27. ACM, 2016. Google Scholar
Digital Library
- R. Hinze, N. Wu, and J. Gibbons. Conjugate hylomorphisms - or: The mother of all structured recursion schemes. In S. K. Rajamani and D. Walker, editors, Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2015, Mumbai, India, January 15-17, 2015 , pages 527–538. ACM, 2015. Google Scholar
Digital Library
- M. Hofmann, B. C. Pierce, and D. Wagner. Symmetric lenses. In T. Ball and M. Sagiv, editors, Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011 , pages 371–384. ACM, 2011. Google Scholar
Digital Library
- M. P. Jones. Coherence for qualified types. Technical Report YALEU/DCS/RR-989, Yale University, 1993.Google Scholar
- M. P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google Scholar
Digital Library
- M. P. Jones. Type classes with functional dependencies. In G. Smolka, editor, Programming Languages and Systems, 9th European Symposium on Programming, ESOP 2000, Held as Part of the European Joint Conferences on the Theory and Practice of Software, ETAPS 2000, Berlin, Germany, March 25 - April 2, 2000, Proceedings , volume 1782 of Lecture Notes in Computer Science , pages 230–244. Springer, 2000. Google Scholar
Digital Library
- O. Kiselyov, R. Lämmel, and K. Schupke. Strongly typed heterogeneous collections. In H. Nilsson, editor, Proceedings of the ACM SIGPLAN Workshop on Haskell, Haskell 2004, Snowbird, UT, USA, September 22-22, 2004 , pages 96–107. ACM, 2004. Google Scholar
Digital Library
- E. Kmett. The lens package, version 4.16, 2018.Google Scholar
- O. Lee and K. Yi. Proofs about a folklore let-polymorphic type inference algorithm. ACM Trans. Program. Lang. Syst., 20(4): 707–723, 1998. Google Scholar
Digital Library
- D. Leijen. Extensible records with scoped labels. In Revised Selected Papers from the Sixth Symposium on Trends in Functional Programming, TFP 2005, Tallinn, Estonia, 23-24 September 2005. , pages 179–194, 2005.Google Scholar
- D. Leijen. Koka: Programming with row polymorphic effect types. In P. Levy and N. Krishnaswami, editors, Proceedings 5th Workshop on Mathematically Structured Functional Programming, [email protected] 2014, Grenoble, France, 12 April 2014. , volume 153 of EPTCS, pages 100–126, 2014.Google Scholar
Cross Ref
- D. Leijen. Type directed compilation of row-typed algebraic effects. In G. Castagna and A. D. Gordon, editors, Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017 , pages 486–499. ACM, 2017. Google Scholar
Digital Library
- S. Liang, P. Hudak, and M. P. Jones. Monad transformers and modular interpreters. In R. K. Cytron and P. Lee, editors, Conference Record of POPL’95: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Francisco, California, USA, January 23-25, 1995 , pages 333–343. ACM Press, 1995. Google Scholar
Digital Library
- S. Lindley and J. Cheney. Row-based effect types for database integration. In B. C. Pierce, editor, Proceedings of TLDI 2012: The Seventh ACM SIGPLAN Workshop on Types in Languages Design and Implementation, Philadelphia, PA, USA, Saturday, January 28, 2012 , pages 91–102. ACM, 2012. Google Scholar
Digital Library
- S. Lindley and J. G. Morris. Lightweight functional session types. In S. Gay and A. Ravara, editors, Behavioural Types: from Theory to Tools . River Publishers, 2017.Google Scholar
- S. Lindley, C. McBride, and C. McLaughlin. Do be do be do. In G. Castagna and A. D. Gordon, editors, Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017 , pages 500–514. ACM, 2017. Google Scholar
Digital Library
- H. Makholm and J. B. Wells. Type inference, principal typings, and let-polymorphism for first-class mixin modules. In O. Danvy and B. C. Pierce, editors, Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, ICFP 2005, Tallinn, Estonia, September 26-28, 2005 , pages 156–167. ACM, 2005. Google Scholar
Digital Library
- J. McKinna. Complements witness consistency. In [email protected], volume 1571 of CEUR Workshop Proceedings, pages 90–94. CEUR-WS.org, 2016.Google Scholar
- J. C. Mitchell. Polymorphic type inference and containment. Inf. Comput., 76(2-3):211–249, Feb. 1988. Google Scholar
Digital Library
- J. G. Morris. A simple semantics for Haskell overloading. In W. Swierstra, editor, Proceedings of the 2014 ACM SIGPLAN symposium on Haskell, Gothenburg, Sweden, September 4-5, 2014 , pages 107–118. ACM, 2014. Google Scholar
Digital Library
- J. G. Morris. Variations on variants. In B. Lippmeier, editor, Proceedings of the 8th ACM SIGPLAN Symposium on Haskell, Haskell ’15, pages 71–81, Vancouver, BC, 2015. ACM. Google Scholar
Digital Library
- B. Oliveira, S. Mu, and S. You. Modular reifiable matching: a list-of-functors approach to two-level types. In Haskell, pages 82–93. ACM, 2015. Google Scholar
Digital Library
- B. Oliveira, Z. Shi, and J. Alpuim. Disjoint intersection types. In J. Garrigue, G. Keller, and E. Sumii, editors, Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016 , pages 364–377. ACM, 2016. Google Scholar
Digital Library
- M. Pickering, J. Gibbons, and N. Wu. Profunctor Optics: Modular Data Accessors. The Art, Science, and Engineering of Programming , 1(2), 2017. Article 7.Google Scholar
- F. Pottier and D. Rémy. The essence of ML type inference. In B. C. Pierce, editor, Advanced Topics in Types and Programming Languages . The MIT Press, 2005.Google Scholar
- D. Rémy. Typechecking records and variants in a natural extension of ML. In Conference Record of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, Austin, Texas, USA, January 11-13, 1989 , pages 77–88. ACM Press, 1989. Google Scholar
Digital Library
- T. Sheard and E. Pasalic. Two-level types and parameterized modules. J. Funct. Program., 14(5):547–587, 2004. Google Scholar
Digital Library
- W. Swierstra. Data types à la carte. J. Funct. Program., 18(04):423–436, 2008. Google Scholar
Digital Library
- P. Wadler. The expression problem. http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt , 1998.Google Scholar
- M. Wand. Complete type inference for simple objects. In Proceedings of the Symposium on Logic in Computer Science (LICS ’87), Ithaca, New York, USA, June 22-25, 1987 , pages 37–44. IEEE Computer Society, 1987.Google Scholar
- M. Wand. Type inference for record concatenation and multiple inheritance. Inf. Comput., 93(1):1–15, 1991. Google Scholar
Digital Library
Index Terms
Abstracting extensible data types: or, rows by any other name
Recommendations
Qualified types for MLF
ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingMLF is a type system that extends a functional language with impredicative rank-n polymorphism. Type inference remains possible and only in some clearly defined situations, a local type annotation is required. Qualified types are a general concept that ...
Qualified types for MLF
Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingMLF is a type system that extends a functional language with impredicative rank-n polymorphism. Type inference remains possible and only in some clearly defined situations, a local type annotation is required. Qualified types are a general concept that ...






Comments