skip to main content

Gradually structured data

Published:15 October 2021Publication History
Skip Abstract Section

Abstract

Dynamically-typed languages offer easy interaction with ad hoc data such as JSON and S-expressions; statically-typed languages offer powerful tools for working with structured data, notably algebraic datatypes, which are a core feature of typed languages both functional and otherwise. Gradual typing aims to reconcile dynamic and static typing smoothly. The gradual typing literature has extensively focused on the computational aspect of types, such as type safety, effects, noninterference, or parametricity, but the application of graduality to data structuring mechanisms has been much less explored. While row polymorphism and set-theoretic types have been studied in the context of gradual typing, algebraic datatypes in particular have not, which is surprising considering their wide use in practice. We develop, formalize, and prototype a novel approach to gradually structured data with algebraic datatypes. Gradually structured data bridges the gap between traditional algebraic datatypes and flexible data management mechanisms such as tagged data in dynamic languages, or polymorphic variants in OCaml. We illustrate the key ideas of gradual algebraic datatypes through the evolution of a small server application from dynamic to progressively more static checking, formalize a core functional language with gradually structured data, and establish its metatheory, including the gradual guarantees.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a presentation video for the talk at OOPSLA 2021 in the research track. In this paper we introduce GSD a language for working with gradually structured data.

References

  1. Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame for All. In Proceedings of the 38th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2011). ACM Press, Austin, Texas, USA. 201–214. https://doi.org/10.1145/1926385.1926409 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for Free for Free: Parametricity, with and Without Types. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), Sept., 39:1–39:28. https://doi.org/10.1145/3110283 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Felipe Bañados Schwerter, Alison M Clark, Khurram A Jafery, and Ronald Garcia. 2021. Abstracting gradual typing moving forward: precise and space-efficient. Proceedings of the ACM on Programming Languages, 5, POPL (2021), Jan., 1–28. https://doi.org/10.1145/3434342 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2014. A Theory of Gradual Effect Systems. In Proceedings of the 19th ACM SIGPLAN Conference on Functional Programming (ICFP 2014). ACM Press, Gothenburg, Sweden. 283–295. https://doi.org/10.1145/2692915.2628149 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2016. Gradual Type-and-Effect Systems. Journal of Functional Programming, 26 (2016), Sept., 19:1–19:69. https://doi.org/10.1017/S0956796816000162 Google ScholarGoogle ScholarCross RefCross Ref
  6. Spenser Bauman, Carl Friedrich Bolz-Tereick, Jeremy Siek, and Sam Tobin-Hochstadt. 2017. Sound gradual typing: Only mostly dead. Proceedings of the ACM on Programming Languages, 1, OOPSLA (2017), Oct., 1–24. https://doi.org/10.1145/3133878 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Véronique Benzaken, Giuseppe Castagna, and Alain Frisch. 2003. CDuce: An XML-Centric General Purpose Language. In Proceedings of the 8th ACM SIGPLAN Conference on Functional Programming (ICFP 2003). ACM Press, Uppsala, Sweden. https://doi.org/10.1145/944705.944711 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Peter Buneman. 1997. Semistructured Data. In Proceedings of the Sixteenth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (Principles of Database Systems). ACM Press, New York, NY, USA. 117–121. https://doi.org/10.1145/263661.263675 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. John Peter Campora, Sheng Chen, and Eric Walkingshaw. 2018. Casts and costs: Harmonizing safety and performance in gradual typing. Proceedings of the ACM on Programming Languages, 2, ICFP (2018), Sept., 1–30. https://doi.org/10.1145/3236793 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), Sept., 41:1–41:28. https://doi.org/10.1145/3110285 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Giuseppe Castagna, Victor Lanvin, Tommaso Petrucciani, and Jeremy G. Siek. 2019. Gradual typing: a new perspective. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 16:1–16:32. https://doi.org/10.1145/3290329 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Evan Czaplicki and Stephen Chong. 2013. Asynchronous Functional Reactive Programming for GUIs. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2013). ACM Press, Seattle, Washington, USA. 411–422. https://doi.org/10.1145/2499370.2462161 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Mike Fagan. 1991. Soft typing: An approach to type checking for dynamically typed languages. Ph.D. Dissertation. Rice University. https://scholarship.rice.edu/handle/1911/16439Google ScholarGoogle Scholar
  14. Matthias Felleisen and Daniel P. Friedman. 1986. Control Operators, the SECD-Machine, and the λ -calculus. In Proceedings of IFIP Working Conference on Formal Descriptions of Programming Concepts, Martin Wirsing (Ed.). Ebberup, Denmark. 193–219.Google ScholarGoogle Scholar
  15. Ronald Garcia and Matteo Cimini. 2015. Principal Type Schemes for Gradual Programs. In Proceedings of the 42nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2015). ACM Press, Mumbai, India. 303–315. https://doi.org/10.1145/2775051.2676992 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016), Rastislav Bodík and Rupak Majumdar (Eds.). ACM Press, St Petersburg, FL, USA. 429–442. https://doi.org/10.1145/2837614.2837670 See erratum: https://www.cs.ubc.ca/ rxg/agt-erratum.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ronald Garcia, Éric Tanter, Roger Wolff, and Jonathan Aldrich. 2014. Foundations of Typestate-Oriented Programming. ACM Transactions on Programming Languages and Systems, 36, 4 (2014), Article 12, Oct., 12:1–12:44 pages. https://doi.org/10.1145/2629609 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jacques Garrigue. 1998. Programming with polymorphic variants. In ML Workshop. 13, 7.Google ScholarGoogle Scholar
  19. Panicz Maciej Godek. 2020. SRFI 200: Pattern Matching. https://srfi.schemers.org/srfi-200/srfi-200.htmlGoogle ScholarGoogle Scholar
  20. Michael Greenberg. 2019. The Dynamic Practice and Static Theory of Gradual Typing. In 3rd Summit on Advances in Programming Languages (SNAPL 2019), Benjamin S. Lerner, Rastislav Bodík, and Shriram Krishnamurthi (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 136). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Providence, RI, USA. 6:1–6:20. https://doi.org/10.4230/LIPIcs.SNAPL.2019.6 Google ScholarGoogle ScholarCross RefCross Ref
  21. Ben Greenman, Asumu Takikawa, Max S New, Daniel Feltey, Robert Bruce Findler, Jan Vitek, and Matthias Felleisen. 2019. How to evaluate the performance of gradual type systems. jfp, 29 (2019), https://doi.org/10.1017/S0956796818000217 Google ScholarGoogle ScholarCross RefCross Ref
  22. David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient gradual typing. Higher-Order and Sympolic Computation, 23, 2 (2010), June, 167–189. https://doi.org/10.1007/s10990-011-9066-z Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Atsushi Igarashi, Peter Thiemann, Vasco T. Vasconcelos, and Philip Wadler. 2017. Gradual Session Types. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), Sept., 38:1–38:28. https://doi.org/10.1145/3110282 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On Polymorphic Gradual Typing. Proceedings of the ACM on Programming Languages, 1, ICFP (2017), Sept., 40:1–40:29. https://doi.org/10.1145/3110284 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Khurram A. Jafery and Joshua Dunfield. 2017. Sums of Uncertainty: Refinements Go Gradual. In Proceedings of the 44th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2017). ACM Press, Paris, France. 804–817. https://doi.org/10.1145/3009837.3009865 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Richard Kelsey. 1999. SRFI 9: Defining Record Types. https://srfi.schemers.org/srfi-9/srfi-9.htmlGoogle ScholarGoogle Scholar
  27. Steve Klabnik and Carol Nichols. 2018. The Rust Programming Language. No Starch Press.Google ScholarGoogle Scholar
  28. Andre Kuhlenschmidt, Deyaaeldeen Almahallawi, and Jeremy G Siek. 2019. Toward efficient gradual typing for structural types via coercions. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). ACM Press, Phoenix, AZ, USA. 517–532. https://doi.org/10.1145/3314221.3314627 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In Proceedings of the 44th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2017). ACM Press, Paris, France. 775–788. https://doi.org/10.1145/3009837.3009856 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Daan Leijen. 2017. Type Directed Compilation of Row-Typed Algebraic Effects. In Proceedings of the 44th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2017). ACM Press, Paris, France. 486–499. https://doi.org/10.1145/3093333.3009872 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Xavier Leroy, Damien Doligez, Alain Frisch, Jacques Garrigue, Didier Rémy, and Jérôme Vouillon. 2021. The OCaml system, release 4.12, Documentation and user’s manual.. 27 Jan., https://ocaml.org/releases/4.12/ocaml-4.12-refman.pdfGoogle ScholarGoogle Scholar
  32. Max S. New, Dustin Jamner, and Amal Ahmed. 2020. Graduality and Parametricity: Together Again for the First Time. Proceedings of the ACM on Programming Languages, 4, POPL (2020), Jan., 46:1–46:32. https://doi.org/10.1145/3371114 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. 2006. An overview of the Scala programming language. EPFL. https://www.scala-lang.org/docu/files/ScalaOverview.pdfGoogle ScholarGoogle Scholar
  34. Oxford. 2021. Oxford Advanced Learner’s Dictionary (10th ed.). Oxford University Press. Evidence.Google ScholarGoogle Scholar
  35. Taro Sekiyama and Atsushi Igarashi. 2020. Gradual Typing for Extensibility by Rows. Jan., Workshop on Gradual Typing (WGT).Google ScholarGoogle Scholar
  36. Ilya Sergey and Dave Clarke. 2012. Gradual Ownership Types. In Proceedings of the 21st European Symposium on Programming Languages and Systems (ESOP 2012), Helmut Seidl (Ed.) (Lecture Notes in Computer Science, Vol. 7211). Springer-Verlag, Tallinn, Estonia. 579–599. https://doi.org/10.1007/978-3-642-28869-2_29 Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Jeremy Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Proceedings of the Scheme and Functional Programming Workshop. 81–92.Google ScholarGoogle Scholar
  38. Jeremy Siek and Walid Taha. 2007. Gradual Typing for Objects. In Proceedings of the 21st European Conference on Object-oriented Programming (ECOOP 2007), Erik Ernst (Ed.) (Lecture Notes in Computer Science, 4609). Springer-Verlag, Berlin, Germany. 2–27. https://doi.org/10.1007/978-3-540-73589-2_2 Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Jeremy Siek and Sam Tobin-Hochstadt. 2016. The Recursive Union of Some Gradual Types. In Wadler Festschrift (Lecture Notes in Computer Science, Vol. 9600). Springer-Verlag, 388–410. https://doi.org/10.1007/978-3-319-30936-1_21 Google ScholarGoogle ScholarCross RefCross Ref
  40. Jeremy Siek and Philip Wadler. 2010. Threesomes, with and without blame. In Proceedings of the 37th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2010). ACM Press, Madrid, Spain. 365–376. https://doi.org/10.1145/1707801.1706342 Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 32). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Asilomar, California, USA. 274–293. https://doi.org/10.4230/LIPIcs.SNAPL.2015.274 Google ScholarGoogle ScholarCross RefCross Ref
  42. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, Sam Tobin-Hochstadt, and Ronald Garcia. 2015. Monotonic References for Efficient Gradual Typing. In Proceedings of the 24th European Symposium on Programming Languages and Systems (ESOP 2015), Jan Vitek (Ed.) (Lecture Notes in Computer Science, Vol. 9032). Springer-Verlag, London, UK. 432–456. https://doi.org/10.1007/978-3-662-46669-8_18 Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Martin Sulzmann, Manuel MT Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with type equality coercions. In Proceedings of the 2007 ACM SIGPLAN international workshop on Types in languages design and implementation. acm, Nice, France. 53–66. https://doi.org/10.1145/1190315.1190324 Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Asumu Takikawa, Daniel Feltey, Ben Greenman, Max S. New, Jan Vitek, and Matthias Felleisen. 2016. Is sound gradual typing dead? In Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2016), Rastislav Bodík and Rupak Majumdar (Eds.). ACM Press, St Petersburg, FL, USA. 456–468. https://doi.org/10.1145/2837614.2837630 Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Asumu Takikawa, T. Stephen Strickland, Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Gradual Typing for First-Class Classes. In Proceedings of the 27th ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 2012). ACM Press, Tucson, AZ, USA. 793–810. https://doi.org/10.1145/2398857.2384674 Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Sam Tobin-Hochstadt and Matthias Felleisen. 2008. The Design and Implementation of Typed Scheme. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2008). ACM Press, San Francisco, CA, USA. 395–406. https://doi.org/10.1145/1328438.1328486 Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Sam Tobin-Hochstadt, Vincent St-Amour, and Eric Dobson. 2014. The Typed Racket Reference.Google ScholarGoogle Scholar
  48. Matías Toro, Elizabeth Labrada, and Éric Tanter. 2019. Gradual Parametricity, Revisited. Proceedings of the ACM on Programming Languages, 3, POPL (2019), Jan., 17:1–17:30. https://doi.org/10.1145/3290330 Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Matías Toro and Éric Tanter. 2017. A Gradual Interpretation of Union Types. In Proceedings of the 24th Static Analysis Symposium (SAS 2017) (Lecture Notes in Computer Science, Vol. 10422). Springer-Verlag, New York City, NY, USA. 382–404. https://doi.org/10.1007/978-3-319-66706-5_19 Google ScholarGoogle ScholarCross RefCross Ref
  50. Matías Toro and Éric Tanter. 2020. Abstracting Gradual References. Science of Computer Programming, 197 (2020), Oct., 1–65. https://doi.org/10.1016/j.scico.2020.102496 Google ScholarGoogle ScholarCross RefCross Ref
  51. Niki Vazou, Éric Tanter, and David Van Horn. 2018. Gradual Liquid Type Inference. Proceedings of the ACM on Programming Languages, 2, OOPSLA (2018), Nov., 132:1–132:25. https://doi.org/10.1145/3276502 Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Mitchell Wand. 1987. Complete Type Inference for Simple Objects. In Proceedings of the Symposium on Logic in Computer Science (LICS 1987). IEEE Computer Society Press, Ithaca, New York, USA. 37–44.Google ScholarGoogle Scholar
  53. Mitchell Wand. 1991. Type inference for record concatenation and multiple inheritance. Information and Computation, 93, 1 (1991), 1–15. https://doi.org/10.1016/0890-5401(91)90050-C Selections from 1989 IEEE Symposium on Logic in Computer Science. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Roger Wolff, Ronald Garcia, Éric Tanter, and Jonathan Aldrich. 2011. Gradual Typestate. In Proceedings of the 25th European Conference on Object-oriented Programming (ECOOP 2011), Mira Mezini (Ed.) (Lecture Notes in Computer Science, Vol. 6813). Springer-Verlag, Lancaster, UK. 459–483. https://doi.org/10.1007/978-3-642-22655-7_22 Google ScholarGoogle ScholarCross RefCross Ref
  55. Matthias Zenger and Martin Odersky. 2001. Extensible Algebraic Datatypes with Defaults. In Proceedings of the 6th ACM SIGPLAN Conference on Functional Programming (ICFP 2001). ACM Press, Florence, Italy. 241–252. https://doi.org/10.1145/507635.507665 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Gradually structured data

      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

      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!