Understanding functional dependencies via constraint handling rules

Functional dependencies are a popular and useful extension to Haskell style type classes. We give a reformulation of functional dependencies in terms of Constraint Handling Rules (CHRs). In previous work, CHRs have been employed for describing user-programmable type extensions in the context of Haskell style type classes. Here, we make use of CHRs to provide for the first time a concise result that under some sufficient conditions, functional dependencies allow for sound, complete and decidable type inference. The sufficient conditions imposed on functional dependencies can be very limiting. We show how to safely relax these conditions and suggest several sound extensions of functional dependencies. Our results allow for a better understanding of functional dependencies and open up the opportunity for new applications.

[1]  Martin Sulzmann A General Type Inference Framework for Hindley/Milner Style Systems , 2001, FLOPS.

[2]  Atsushi Ohori,et al.  A polymorphic record calculus and its compilation , 1995, TOPL.

[3]  Simon L. Peyton Jones,et al.  Sound and Decidable Type Inference for Functional Dependencies , 2004, ESOP.

[4]  Jack Minker Foundations of deductive databases and logic programming , 1988 .

[5]  Thom W. Frühwirth,et al.  Proving Termination of Constraint Solver Programs , 1999, New Trends in Constraints.

[6]  Mark P. Jones Simplifying and improving qualified types , 1995, FPCA '95.

[7]  Simon L. Peyton Jones,et al.  Associated types with class , 2005, POPL '05.

[8]  Dionysios S. Kalogerias,et al.  A Proofs A . 1 Proof of Theorem 1 ( Sufficient number of samples ) Lemmas , .

[9]  Paul Hudak,et al.  Parametric type classes , 1992, LFP '92.

[10]  Thom W. Frühwirth,et al.  Theory and Practice of Constraint Handling Rules , 1998, J. Log. Program..

[11]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[12]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[13]  Thom W. Frühwirth,et al.  Constraint Handling Rules , 2009, Constraint Programming.

[14]  Simon L. Peyton Jones,et al.  Type classes in Haskell , 1994, TOPL.

[15]  Mark Philip Jones Qualified types: theory and practice (ordering relation) , 1992 .

[16]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[17]  P. Hudak,et al.  A general framework for hindley/milner type systems with constraints , 2000 .

[18]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[19]  David Maier,et al.  The Theory of Relational Databases , 1983 .

[20]  W. W. Armstrong,et al.  Dependency Structures of Data Base Relationships , 1974, IFIP Congress.

[21]  Mark P. Jones Qualified Types: Theory and Practice , 1994 .

[22]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[23]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[24]  Slim Abdennadher,et al.  Operational Semantics and Confluence of Constraint Propagation Rules , 1997, CP.

[25]  Mark P. Jones Coherence for qualified types , 2001 .

[26]  Dominic Duggan,et al.  Type-checking multi-parameter type classes , 2002, J. Funct. Program..