Advertisement

Type Processing by Constraint Reasoning

  • Peter J. Stuckey
  • Martin Sulzmann
  • Jeremy Wazny
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4279)

Abstract

Herbrand constraint solving or unification has long been understood as an efficient mechanism for type checking and inference for programs using Hindley/Milner types. If we step back from the particular solving mechanisms used for Hindley/Milner types, and understand type operations in terms of constraints we not only give a basis for handling Hindley/Milner extensions, but also gain insight into type reasoning even on pure Hindley/Milner types, particularly for type errors. In this paper we consider typing problems as constraint problems and show which constraint algorithms are required to support various typing questions. We use a light weight constraint reasoning formalism, Constraint Handling Rules, to generate suitable algorithms for many popular extensions to Hindley/Milner types. The algorithms we discuss are all implemented as part of the freely available Chameleon system.

Keywords

Functional Dependency Type Error Typing Problem Type Class Type Processing 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abdennadher, S.: Operational semantics and confluence of constraint propagation rules. In: Smolka, G. (ed.) CP 1997. LNCS, vol. 1330, pp. 252–266. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  2. 2.
    Beaven, M., Stansifer, R.: Explaining type errors in polymorphic languages. ACM Letters on Programming Languages 2, 17–30 (1993)CrossRefGoogle Scholar
  3. 3.
    Cheney, J., Hinze, R.: First-class phantom types. Technical Report CUCIS TR2003-1901, Cornell University (2003)Google Scholar
  4. 4.
    Chitil, O.: Compositional explanation of types and algorithmic debugging of type errors. In: Proc. of ICFP 2001, pp. 193–204. ACM Press, New York (2001)CrossRefGoogle Scholar
  5. 5.
    Demoen, B., de la Banda, M.G., Stuckey, P.J.: Type constraint solving for parametric and ad-hoc polymorphism. In: Proc. of the 22nd Australian Computer Science Conference, pp. 217–228. Springer, Heidelberg (1999)Google Scholar
  6. 6.
    Duck, G.J., Peyton-Jones, S., Stuckey, P.J., Sulzmann, M.: Sound and decidable type inference for functional dependencies. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 49–63. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  7. 7.
    Duggan, D., Bent, F.: Explaining type inference. Science of Computer Programming 27(1), 37–83 (1996)MATHCrossRefGoogle Scholar
  8. 8.
    Frühwirth, T.: Constraint handling rules. In: Podelski, A. (ed.) Constraint Programming: Basics and Trends. LNCS, vol. 910. Springer, Heidelberg (1995)Google Scholar
  9. 9.
    de la Banda, M.G., Stuckey, P.J., Wazny, J.: Finding all minimal unsatisfiable constraints. In: Proc. of PPDP 2003, pp. 32–43. ACM Press, New York (2003)CrossRefGoogle Scholar
  10. 10.
    Haack, C., Wells, J.B.: Type error slicing in implicitly typed higher-order languages. In: Degano, P. (ed.) ESOP 2003. LNCS, vol. 2618, pp. 284–301. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  11. 11.
  12. 12.
    Heeren, B., Hage, J.: Parametric type inferencing for Helium. Technical Report UU-CS-2002-035, Utrecht University (2002)Google Scholar
  13. 13.
    Heeren, B., Hage, J.: Type class directives. In: Hermenegildo, M.V., Cabeza, D. (eds.) PADL 2004. LNCS, vol. 3350, pp. 253–267. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  14. 14.
    Heeren, B., Hage, J., Swierstra, D.: Generalizing Hindley-Milner type inference algorithms. Technical Report UU-CS-2002-031, Utrecht University (2002)Google Scholar
  15. 15.
  16. 16.
  17. 17.
    Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, pp. 230–244. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  18. 18.
    Lee, O., Yi, K.: A generalized let-polymorphic type inference algorithm. Technical Memorandum ROPAS-2000-5, National Creative Research Center, Korea Advanced Institute of Science and Technology (March 2000)Google Scholar
  19. 19.
    Maher, M.J.: Herbrand constraint abduction. In: 20th IEEE Symposium on Logic in Computer Science (LICS 2005), pp. 397–406. IEEE Computer Society Press, Los Alamitos (2005)CrossRefGoogle Scholar
  20. 20.
    Marriott, K., Stuckey, P.J.: Programming with Constraints: an Introduction. MIT Press, Cambridge (1998)MATHGoogle Scholar
  21. 21.
    McAdam, B.J.: Generalising techniques for type debugging. Trends in Functional Programming, 49–57 (March 2000)Google Scholar
  22. 22.
    Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)MATHCrossRefMathSciNetGoogle Scholar
  23. 23.
    nhc98 home page, haskell.org/nhc98/
  24. 24.
    Nilsson, H.: Dynamic optimization for functional reactive programming using generalized algebraic data types. In: Proc. of ICFP 2005, pp. 54–65. ACM Press, New York (2005)CrossRefGoogle Scholar
  25. 25.
    Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization. In: Proc. of POPL 2004, pp. 89–98. ACM Press, New York (2004)CrossRefGoogle Scholar
  26. 26.
    Sheard, T., Pasalic, E.: Meta-programming with built-in type equality. In: Fourth International Workshop on Logical Frameworks and Meta-Languages (2004)Google Scholar
  27. 27.
    Shoenfield, J.R.: Mathematical Logic. Addison-Wesley, Reading (1967)MATHGoogle Scholar
  28. 28.
    Stuckey, P.J., Sulzmann, M.: A theory of overloading. ACM Transactions on Programming Languages and Systems 27(6), 1216–1269 (2005)CrossRefGoogle Scholar
  29. 29.
    Stuckey, P.J., Sulzmann, M., Wazny, J.: The Chameleon type debugger (tool demonstration). In: Ronsse, M. (ed.) Proceedings of the Fifth International Workshop on Automated Debugging, pp. 247–260 (2003), http://arxiv.org/html/cs.SE/0309027
  30. 30.
    Stuckey, P.J., Sulzmann, M., Wazny, J.: Interactive type debugging in Haskell. In: Juring, J. (ed.) Proceedings of the ACM SIGPLAN 2003 Haskell Workshop, pp. 72–83. ACM Press, New York (2003)CrossRefGoogle Scholar
  31. 31.
    Stuckey, P.J., Sulzmann, M., Wazny, J.: Improving type error diagnosis. In: Proceedings of the ACM SIGPLAN 2004 Haskell Workshop, pp. 80–91. ACM Press, New York (2004)CrossRefGoogle Scholar
  32. 32.
    Sulzmann, M., Wazny, J.: Chameleon, http://www.comp.nus.edu.sg/~sulzmann/chameleon
  33. 33.
    Sulzmann, M., Wazny, J., Stuckey, P.J.: A framework for extended algebraic data types. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 47–64. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  34. 34.
    Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad-hoc. In: Proc. of POPL 1989, pp. 60–76. ACM Press, New York (1989)Google Scholar
  35. 35.
    Wazny, J.: Type inference and type error diagnosis for Hindley/Milner with extensions. PhD thesis, University of Melbourne (2006), http://www.comp.nus.edu.sg/~sulzmann/chameleon/thesis.ps.gz
  36. 36.
    Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proc. of POPL 2003, pp. 224–235. ACM Press, New York (2003)CrossRefGoogle Scholar
  37. 37.
    Yang, J., Wells, J., Trinder, P., Michaelson, G.: Improved type error reporting. In: Proceedings of 12th International Workshop on Implementation of Functional Languages, pp. 71–86 (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Peter J. Stuckey
    • 1
    • 2
  • Martin Sulzmann
    • 3
  • Jeremy Wazny
    • 2
  1. 1.NICTA Victoria Laboratory 
  2. 2.Department of Computer Science and Software EngineeringUniversity of MelbourneAustralia
  3. 3.School of ComputingNational University of SingaporeSingapore

Personalised recommendations