skip to main content
article

Elaboration on functional dependencies: functional dependencies are dead, long live functional dependencies!

Published:07 September 2017Publication History
Skip Abstract Section

Abstract

Functional dependencies are a popular extension to Haskell's type-class system because they provide fine-grained control over type inference, resolve ambiguities and even enable type-level computations.

Unfortunately, several aspects of Haskell's functional dependencies are ill-understood. In particular, the GHC compiler does not properly enforce the functional dependency property, and rejects well-typed programs because it does not know how to elaborate them into its core language, System FC.

This paper presents a novel formalization of functional dependencies that addresses these issues: We explicitly capture the functional dependency property in the type system, in the form of explicit type equalities. We also provide a type inference algorithm and an accompanying elaboration strategy which allows all well-typed programs to be elaborated into System FC.

References

  1. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. 2005. Associated Type Synonyms. SIGPLAN Not. 40, 9 (2005), 241–253. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. 2005. Associated Types with Class. SIGPLAN Not. 40, 1 (2005), 1–13. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Stéphane Ducasse, Oscar Nierstrasz, Nathanael Schärli, Roel Wuyts, and Andrew P. Black. 2006. Traits: A Mechanism for Fine-grained Reuse. ACM Trans. Program. Lang. Syst. 28, 2 (2006), 331–388. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Gregory J. Duck, Simon Peyton-Jones, Peter J. Stuckey, and Martin Sulzmann. 2004. Sound and Decidable Type Inference for Functional Dependencies. In TOPLAS. Lecture Notes in Computer Science, Vol. 2986. Springer, 49–63.Google ScholarGoogle ScholarCross RefCross Ref
  5. Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. 2014. Closed Type Families with Overlapping Equations. In POPL ’14. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Thom W. Frühwirth. 1995. Constraint Handling Rules. In Selected Papers from Constraint Programming: Basics and Trends. Springer-Verlag, 90–107.Google ScholarGoogle Scholar
  7. Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Douglas Gregor, Jaakko Järvi, Jeremy Siek, Bjarne Stroustrup, Gabriel Dos Reis, and Andrew Lumsdaine. 2006. Concepts: Linguistic Support for Generic Programming in C++. SIGPLAN Not. 41, 10 (2006), 291–310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type Classes in Haskell. ACM Trans. Program. Lang. Syst. 18, 2 (1996). Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Fergus Henderson, Thomas Conway, Zoltan Somogyi, David Jeffery, Peter Schachte, Simon Taylor, and Chris Speirs. 1996. The Mercury Language Reference Manual. Technical Report.Google ScholarGoogle Scholar
  11. Mark Jones. 2010. The Habit Programming Language: The Revised Preliminary Report.Google ScholarGoogle Scholar
  12. Mark P. Jones. 1992. A theory of qualified types. In ESOP ’92. Lecture Notes in Computer Science, Vol. 582. Springer Berlin Heidelberg, 287–306. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Mark P. Jones. 1993. A System of Constructor Classes: Overloading and Implicit Higher-order Polymorphism. In FPCA ’93. ACM, 52–61. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Mark P. Jones. 1995. Simplifying and Improving Qualified Types. In FPCA ’95. ACM, 160–169. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Mark P. Jones. 2000. Type Classes with Functional Dependencies. In Programming Languages and Systems. Lecture Notes in Computer Science, Vol. 1782. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Mark P. Jones and Iavor S. Diatchki. 2008. Language and Program Design for Functional Dependencies. SIGPLAN Not. 44, 2 (2008), 87–98. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Simon Peyton Jones. 1997. Bulk Types With Class. In Proceedings of the Second Haskell Workshop.Google ScholarGoogle Scholar
  18. Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly Typed Heterogeneous Collections. In Haskell ’04. ACM, 96–107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. The Coq development team. 2004. The Coq proof assistant reference manual. LogiCal Project. http://coq.inria.fr Version 8.0.Google ScholarGoogle Scholar
  20. Simon Peyton Jones. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.Google ScholarGoogle Scholar
  21. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple Unification-based Type Inference for GADTs. In ICFP ’06. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. 2008. Type Checking with Open Type Functions. In ICFP ’08. ACM, 51–62. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann, and Dimitrios Vytiniotis. 2009. Complete and Decidable Type Inference for GADTs. In ICFP ’09. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Tom Schrijvers and Martin Sulzmann. 2008. Unified type checking for classes and type families. (2008). https://lirias.kuleuven.be/handle/123456789/186697Google ScholarGoogle Scholar
  25. Tom Schrijvers, Martin Sulzmann, Simon Peyton Jones, and Manuel Chakravarty. 2007. Towards open type functions for Haskell. In IFL ’07. 233–251.Google ScholarGoogle Scholar
  26. Alejandro Serrano, Jurriaan Hage, and Patrick Bahr. 2015. Type Families with Class, Type Classes with Family. SIGPLAN Not. 50, 12 (2015), 129–140. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Nathanael Shärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew Black. 2002. Traits: Composable Units of Behavior. Technical Report. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Abraham Silberschatz, Henry Korth, and S. Sudarshan. 2006. Database Systems Concepts (5 ed.). McGraw-Hill, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Jan Stolarek, Simon Peyton Jones, and Richard A. Eisenberg. 2015. Injective Type Families for Haskell. SIGPLAN Not. 50, 12 (2015), 118–128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Peter J. Stuckey and Martin Sulzmann. 2005. A Theory of Overloading. ACM Trans. Program. Lang. Syst. 27, 6 (2005), 1216–1269. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with Type Equality Coercions. In TLDI ’07. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Martin Sulzmann, Gregory J. Duck, Simon Peyton-Jones, and Peter J. Stuckey. 2007. Understanding Functional Dependencies via Constraint Handling Rules. J. Funct. Program. 17, 1 (2007), 83–129. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let Should Not Be Generalized. In TLDI ’10. ACM, 39–50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Dimitrios Vytiniotis, Simon Peyton jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(x) Modular Type Inference with Local Assumptions. J. Funct. Program. 21, 4-5 (2011), 333–412. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. P. Wadler and S. Blott. 1989. How to Make Ad-hoc Polymorphism Less Ad Hoc. In POPL ’89. ACM, 60–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a Promotion. In TLDI ’12. ACM, 53–66. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Elaboration on functional dependencies: functional dependencies are dead, long live functional dependencies!

      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 52, Issue 10
        Haskell '17
        October 2017
        211 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3156695
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on Haskell
          September 2017
          211 pages
          ISBN:9781450351829
          DOI:10.1145/3122955

        Copyright © 2017 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 7 September 2017

        Check for updates

        Qualifiers

        • 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!