skip to main content
article

Quantified class constraints

Published:07 September 2017Publication History
Skip Abstract Section

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.

References

  1. Jean-marc Andreoli. 1992. Logic Programming with Focusing Proofs in Linear Logic. Journal of Logic and Computation 2 (1992), 297–347.Google ScholarGoogle ScholarCross RefCross Ref
  2. Richard S. Bird and Lambert G. L. T. Meertens. 1998. Nested Datatypes. In MPC ’98 . Springer, 52–67. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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
  4. Satvik Chauhan, Piyush P. Kurur, and Brent A. Yorgey. 2016. How to Twist Pointers Without Breaking Them. In Haskell 2016. ACM, 51–61. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Luis Damas and Robin Milner. 1982. Principal Type-schemes for Functional Programs. In POPL ’82. ACM, 207–212. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Peng Fu, Ekaterina Komendantskaya, Tom Schrijvers, and Andrew Pond. 2016. Proof Relevant Corecursive Resolution. In FLOPS 2016. Springer, 126–143.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. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Ronald Harrop. 1956. On disjunctions and existential statements in intuitionistic systems of logic. Math. Ann. 132, 4 (1956), 347–361.Google ScholarGoogle ScholarCross RefCross Ref
  10. Ralf Hinze. 2000. Perfect trees and bit-reversal permutations. JFP 10, 3 (2000), 305–317. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ralf Hinze. 2010. Adjoint Folds and Unfolds: Or: Scything Through the Thicket of Morphisms. In MPC’10. Springer, 195–228. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Ralf Hinze and Simon Peyton Jones. 2000. Derivable Type Classes. In Proceedings of the Fourth Haskell Workshop . Elsevier Science, 227–236.Google ScholarGoogle Scholar
  13. Mauro Jaskelioff. 2011. Monatron: an extensible monad transformer library. In IFL’08 . Springer, Berlin, Heidelberg, 233–248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Mark P. Jones. 1995. Functional Programming with Overloading and HigherOrder Polymorphism. In Advanced Functional Programming. Springer, 97–136. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Mark P. Jones. 1995. Qualified Types: Theory and Practice. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Mark P. Jones. 1995. Simplifying and Improving Qualified Types. In FPCA ’95. ACM, 160–169. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Mark P. Jones. 2000. Type Classes with Functional Dependencies. In Programming Languages and Systems . LNCS, Vol. 1782. Springer Berlin Heidelberg, 230–244. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle Scholar
  20. Edward A. Kmett. 2017. The constraint package. (2017). https://hackage.haskell. org/package/constraints-0.9.1 .Google ScholarGoogle Scholar
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Ralf Lämmel and Simon Peyton Jones. 2005. Scrap Your Boilerplate with Class: Extensible Generic Functions. SIGPLAN Not. 40, 9 (2005), 204–215. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Chuck Liang and Dale Miller. 2009. Focusing and Polarization in Linear, Intuitionistic, and Classical Logics. Theor. Comput. Sci. 410, 46 (2009), 4747–4768. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Dale Miller, Gopalan Nadathur, Frank Pfenning, and Andre Scedrov. 1989. Uniform Proofs As a Foundation for Logic Programming . Technical Report. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. J. Garrett Morris. 2014. A Simple Semantics for Haskell Overloading. SIGPLAN Not. 49, 12 (2014), 107–118. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical Type Inference for Arbitrary-rank Types. JFP 17, 1 (2007). Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. Frank Pfenning. 2010. Lecture Notes on Focusing. (2010). https://www.cs.cmu. edu/~fp/courses/oregon-m10/04-focusing.pdf .Google ScholarGoogle Scholar
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. Tom Schrijvers, Bruno C. d. S. Oliveira, and Philip Wadler. 2017. Cochis: Deterministic and Coherent Implicits . Report CW 705. KU Leuven.Google ScholarGoogle Scholar
  33. Matthieu Sozeau and Nicolas Oury. 2008. First-Class Type Classes. In TPHOLs 2008 (LNCS) , Vol. 5170. Springer, 278–293. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Mike Spivey. 2017. Faster Coroutine Pipelines. In ICFP 2017. accepted. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  36. Valery Trifonov. 2003. Simulating Quantified Class Constraints. In Haskell ’03. ACM, 98–102. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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
  38. 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

Index Terms

  1. Quantified class constraints

      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!