Abstract
Quantified class constraints have been proposed many years ago to raise the expressive power of type classes from Horn clauses to the universal fragment of Hereditiary Harrop logic. Yet, while it has been much asked for over the years, the feature was never implemented or studied in depth. Instead, several workarounds have been proposed, all of which are ultimately stopgap measures.
This paper revisits the idea of quantified class constraints and elaborates it into a practical language design. We show the merit of quantified class constraints in terms of more expressive modeling and in terms of terminating type class resolution. In addition, we provide a declarative specification of the type system as well as a type inference algorithm that elaborates into System F. Moreover, we discuss termination conditions of our system and also provide a prototype implementation.
- Jean-marc Andreoli. 1992. Logic Programming with Focusing Proofs in Linear Logic. Journal of Logic and Computation 2 (1992), 297–347.Google Scholar
Cross Ref
- Richard S. Bird and Lambert G. L. T. Meertens. 1998. Nested Datatypes. In MPC ’98 . Springer, 52–67. Google Scholar
Digital Library
- 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
- Satvik Chauhan, Piyush P. Kurur, and Brent A. Yorgey. 2016. How to Twist Pointers Without Breaking Them. In Haskell 2016. ACM, 51–61. Google Scholar
Digital Library
- Luis Damas and Robin Milner. 1982. Principal Type-schemes for Functional Programs. In POPL ’82. ACM, 207–212. Google Scholar
Digital Library
- Peng Fu, Ekaterina Komendantskaya, Tom Schrijvers, and Andrew Pond. 2016. Proof Relevant Corecursive Resolution. In FLOPS 2016. Springer, 126–143.Google Scholar
- Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press. Google Scholar
Digital Library
- Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type Classes in Haskell. ACM TOPLAS 18, 2 (1996), 109–138. Google Scholar
Digital Library
- Ronald Harrop. 1956. On disjunctions and existential statements in intuitionistic systems of logic. Math. Ann. 132, 4 (1956), 347–361.Google Scholar
Cross Ref
- Ralf Hinze. 2000. Perfect trees and bit-reversal permutations. JFP 10, 3 (2000), 305–317. Google Scholar
Digital Library
- Ralf Hinze. 2010. Adjoint Folds and Unfolds: Or: Scything Through the Thicket of Morphisms. In MPC’10. Springer, 195–228. Google Scholar
Digital Library
- Ralf Hinze and Simon Peyton Jones. 2000. Derivable Type Classes. In Proceedings of the Fourth Haskell Workshop . Elsevier Science, 227–236.Google Scholar
- Mauro Jaskelioff. 2011. Monatron: an extensible monad transformer library. In IFL’08 . Springer, Berlin, Heidelberg, 233–248. Google Scholar
Digital Library
- Mark P. Jones. 1992. A theory of qualified types. In ESOP ’92, Bernd KriegBrückner (Ed.). LNCS, Vol. 582. Springer Berlin Heidelberg, 287–306. Google Scholar
Digital Library
- Mark P. Jones. 1995. Functional Programming with Overloading and HigherOrder Polymorphism. In Advanced Functional Programming. Springer, 97–136. Google Scholar
Digital Library
- Mark P. Jones. 1995. Qualified Types: Theory and Practice. Cambridge University Press. 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 . LNCS, Vol. 1782. Springer Berlin Heidelberg, 230–244. Google Scholar
Digital Library
- Simon Peyton Jones, Mark Jones, and Erik Meijer. 1997. Type classes: an exploration of the design space. In Proceedings of the 1997 Haskell Workshop. ACM.Google Scholar
- Edward A. Kmett. 2017. The constraint package. (2017). https://hackage.haskell. org/package/constraints-0.9.1 .Google Scholar
- Ralf Lämmel and Simon Peyton Jones. 2003. Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming. SIGPLAN Not. 38, 3 (2003), 26–37. Google Scholar
Digital Library
- Ralf Lämmel and Simon Peyton Jones. 2005. Scrap Your Boilerplate with Class: Extensible Generic Functions. SIGPLAN Not. 40, 9 (2005), 204–215. Google Scholar
Digital Library
- Chuck Liang and Dale Miller. 2009. Focusing and Polarization in Linear, Intuitionistic, and Classical Logics. Theor. Comput. Sci. 410, 46 (2009), 4747–4768. Google Scholar
Digital Library
- Dale Miller, Gopalan Nadathur, Frank Pfenning, and Andre Scedrov. 1989. Uniform Proofs As a Foundation for Logic Programming . Technical Report. Google Scholar
Digital Library
- J. Garrett Morris. 2014. A Simple Semantics for Haskell Overloading. SIGPLAN Not. 49, 12 (2014), 107–118. Google Scholar
Digital Library
- Bruno C.d.S. Oliveira, Adriaan Moors, and Martin Odersky. 2010. Type Classes As Objects and Implicits. SIGPLAN Not. 45, 10 (2010), 341–360. Google Scholar
Digital Library
- Bruno C.d.S. Oliveira, Tom Schrijvers, Wontae Choi, Wonchan Lee, and Kwangkeun Yi. 2012. The Implicit Calculus: A New Foundation for Generic Programming. SIGPLAN Not. 47, 6 (2012), 35–44. Google Scholar
Digital Library
- Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical Type Inference for Arbitrary-rank Types. JFP 17, 1 (2007). Google Scholar
Digital Library
- Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple Unification-based Type Inference for GADTs. SIGPLAN Not. 41, 9 (2006), 50–61. Google Scholar
Digital Library
- Frank Pfenning. 2010. Lecture Notes on Focusing. (2010). https://www.cs.cmu. edu/~fp/courses/oregon-m10/04-focusing.pdf .Google Scholar
- Tom Schrijvers and Bruno C.d.S. Oliveira. 2011. Monads, Zippers and Views: Virtualizing the Monad Stack. SIGPLAN Not. 46, 9 (2011), 32–44. Google Scholar
Digital Library
- Tom Schrijvers, Bruno C. d. S. Oliveira, and Philip Wadler. 2017. Cochis: Deterministic and Coherent Implicits . Report CW 705. KU Leuven.Google Scholar
- Matthieu Sozeau and Nicolas Oury. 2008. First-Class Type Classes. In TPHOLs 2008 (LNCS) , Vol. 5170. Springer, 278–293. Google Scholar
Digital Library
- Mike Spivey. 2017. Faster Coroutine Pipelines. In ICFP 2017. accepted. Google Scholar
Digital Library
- Martin Sulzmann, Gregory J. Duck, Simon Peyton-Jones, and Peter J. Stuckey. 2007. Understanding Functional Dependencies via Constraint Handling Rules. JFP 17, 1 (2007), 83–129. Google Scholar
Digital Library
- Valery Trifonov. 2003. Simulating Quantified Class Constraints. In Haskell ’03. ACM, 98–102. 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
- 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
Index Terms
Quantified class constraints
Recommendations
Quantified class constraints
Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on HaskellQuantified class constraints have been proposed many years ago to raise the expressive power of type classes from Horn clauses to the universal fragment of Hereditiary Harrop logic. Yet, while it has been much asked for over the years, the feature was ...
Type classes with more higher-order polymorphism
We propose an extension of Haskell's type class system with lambda abstractions in the type language. Type inference for our extension relies on a novel constrained unification procedure called guided higher-order unification. This unification procedure ...
Type classes with more higher-order polymorphism
ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programmingWe propose an extension of Haskell's type class system with lambda abstractions in the type language. Type inference for our extension relies on a novel constrained unification procedure called guided higher-order unification. This unification procedure ...







Comments