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.
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. 2005. Associated Type Synonyms. SIGPLAN Not. 40, 9 (2005), 241–253. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. 2014. Closed Type Families with Overlapping Equations. In POPL ’14. Google Scholar
Digital Library
- Thom W. Frühwirth. 1995. Constraint Handling Rules. In Selected Papers from Constraint Programming: Basics and Trends. Springer-Verlag, 90–107.Google Scholar
- Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Fergus Henderson, Thomas Conway, Zoltan Somogyi, David Jeffery, Peter Schachte, Simon Taylor, and Chris Speirs. 1996. The Mercury Language Reference Manual. Technical Report.Google Scholar
- Mark Jones. 2010. The Habit Programming Language: The Revised Preliminary Report.Google Scholar
- 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 Scholar
Digital Library
- Mark P. Jones. 1993. A System of Constructor Classes: Overloading and Implicit Higher-order Polymorphism. In FPCA ’93. ACM, 52–61. Google Scholar
Digital Library
- Mark P. Jones. 1995. Simplifying and Improving Qualified Types. In FPCA ’95. ACM, 160–169. Google Scholar
Digital Library
- Mark P. Jones. 2000. Type Classes with Functional Dependencies. In Programming Languages and Systems. Lecture Notes in Computer Science, Vol. 1782. Springer. Google Scholar
Digital Library
- Mark P. Jones and Iavor S. Diatchki. 2008. Language and Program Design for Functional Dependencies. SIGPLAN Not. 44, 2 (2008), 87–98. Google Scholar
Digital Library
- Simon Peyton Jones. 1997. Bulk Types With Class. In Proceedings of the Second Haskell Workshop.Google Scholar
- Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly Typed Heterogeneous Collections. In Haskell ’04. ACM, 96–107. Google Scholar
Digital Library
- The Coq development team. 2004. The Coq proof assistant reference manual. LogiCal Project. http://coq.inria.fr Version 8.0.Google Scholar
- Simon Peyton Jones. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.Google Scholar
- Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple Unification-based Type Inference for GADTs. In ICFP ’06. Google Scholar
Digital Library
- Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. 2008. Type Checking with Open Type Functions. In ICFP ’08. ACM, 51–62. Google Scholar
Digital Library
- Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann, and Dimitrios Vytiniotis. 2009. Complete and Decidable Type Inference for GADTs. In ICFP ’09. ACM. Google Scholar
Digital Library
- Tom Schrijvers and Martin Sulzmann. 2008. Unified type checking for classes and type families. (2008). https://lirias.kuleuven.be/handle/123456789/186697Google Scholar
- Tom Schrijvers, Martin Sulzmann, Simon Peyton Jones, and Manuel Chakravarty. 2007. Towards open type functions for Haskell. In IFL ’07. 233–251.Google Scholar
- Alejandro Serrano, Jurriaan Hage, and Patrick Bahr. 2015. Type Families with Class, Type Classes with Family. SIGPLAN Not. 50, 12 (2015), 129–140. Google Scholar
Digital Library
- Nathanael Shärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew Black. 2002. Traits: Composable Units of Behavior. Technical Report. Google Scholar
Digital Library
- Abraham Silberschatz, Henry Korth, and S. Sudarshan. 2006. Database Systems Concepts (5 ed.). McGraw-Hill, Inc. Google Scholar
Digital Library
- Jan Stolarek, Simon Peyton Jones, and Richard A. Eisenberg. 2015. Injective Type Families for Haskell. SIGPLAN Not. 50, 12 (2015), 118–128. Google Scholar
Digital Library
- Peter J. Stuckey and Martin Sulzmann. 2005. A Theory of Overloading. ACM Trans. Program. Lang. Syst. 27, 6 (2005), 1216–1269. Google Scholar
Digital Library
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with Type Equality Coercions. In TLDI ’07. ACM. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Dimitrios Vytiniotis, Simon Peyton Jones, and Tom Schrijvers. 2010. Let Should Not Be Generalized. In TLDI ’10. ACM, 39–50. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- P. Wadler and S. Blott. 1989. How to Make Ad-hoc Polymorphism Less Ad Hoc. In POPL ’89. ACM, 60–76. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Elaboration on functional dependencies: functional dependencies are dead, long live functional dependencies!
Recommendations
Elaboration on functional dependencies: functional dependencies are dead, long live functional dependencies!
Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on HaskellFunctional 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 ...
Language and program design for functional dependencies
HASKELL '08Eight years ago, functional dependencies, a concept from the theory of relational databases, were proposed as a mechanism for avoiding common problems with multiple parameter type classes in Haskell. In this context, functional dependencies give ...
Language and program design for functional dependencies
Haskell '08: Proceedings of the first ACM SIGPLAN symposium on HaskellEight years ago, functional dependencies, a concept from the theory of relational databases, were proposed as a mechanism for avoiding common problems with multiple parameter type classes in Haskell. In this context, functional dependencies give ...







Comments