Advertisement

Partial Type Signatures for Haskell

  • Thomas Winant
  • Dominique Devriese
  • Frank Piessens
  • Tom Schrijvers
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8324)

Abstract

Strong type systems can be used to increase the reliability and performance of programs. In combination with type inference the overhead for the programmer can be kept small. Nevertheless, explicit type signatures often remain needed or useful. In languages with standard Hindley-Milner-based type systems, programmers have a binary choice between omitting the type signature (and rely on type inference) or explicitly providing the type entirely; there are no intermediate options. Proposals for partial type signatures exist, but none support features like local constraints and GHC’s non-generalisation of local bindings. Therefore we propose and motivate a practical form of partial type signatures for present-day Haskell. We formally describe our proposal as an extension of the OutsideIn(X) system and prove some of its properties. We have developed a (not yet complete) implementation for the GHC Haskell compiler. Our design fits naturally in both the OutsideIn(X) formalism and the compiler.

Keywords

Haskell Hindley-Milner type inference (partial) type signatures wildcards 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Bolingbroke, M.: Constraint kinds for GHC (2011), http://blog.omega-prime.co.uk/?p=127
  2. 2.
    Claessen, K., Axelsson, E.: The patch-combinators package. Hackage (2012), http://hackage.haskell.org/package/patch-combinators
  3. 3.
    Dijkstra, A.: Stepping Through Haskell. Ph.D. thesis, Universiteit Utrecht (2005)Google Scholar
  4. 4.
    Dijkstra, A., Swierstra, D.S.: Making implicit parameters explicit. Tech. Rep. UU-CS-2005-032, Universiteit Utrecht (2005)Google Scholar
  5. 5.
    Kiselyov, O.: Partial signatures (August 2004), http://okmij.org/ftp/Haskell/types.html#partial-sigs (visited on December 31, 2012)
  6. 6.
    Leijen, D.: HMF: simple type inference for first-class polymorphism. In: ICFP, pp. 283–294. ACM (2008)Google Scholar
  7. 7.
    Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University and Göteborg University (2007)Google Scholar
  8. 8.
    Peyton Jones, S., Shields, M.: Lexically-scoped type variables (2004)Google Scholar
  9. 9.
    Peyton Jones, S., Vytiniotis, D., Weirich, S., Shields, M.: Practical type inference for arbitrary-rank types. J. Funct. Program. 17(1), 1–82 (2007)CrossRefzbMATHMathSciNetGoogle Scholar
  10. 10.
    Rémy, D.: Simple, partial type-inference for System F based on type-containment. In: ICFP, pp. 130–143. ACM (2005)Google Scholar
  11. 11.
    Sulzmann, M., Wazny, J.: Lexically scoped type annotations (2005) (manuscript), http://www.cs.mu.oz.au/~sulzmann/manuscript/lexical-annot.ps
  12. 12.
    Various authors: Infer type context in a type signature. GHC Ticket (2011), http://hackage.haskell.org/trac/ghc/ticket/5248
  13. 13.
    Vytiniotis, D., Peyton Jones, S., Schrijvers, T., Sulzmann, M.: OutsideIn(X): Modular type inference with local assumptions. J. Funct. Program. 21(4-5), 333–412 (2011)CrossRefzbMATHMathSciNetGoogle Scholar
  14. 14.
    Wallace, M.: Partial type signatures/annotations. Haskell Prime Wiki (February 2006), http://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeAnnotations
  15. 15.
    Wallace, M., et al.: Partial type signatures. Haskell Prime Wiki (January 2006), http://ghc.haskell.org/trac/haskell-prime/wiki/PartialTypeSigs
  16. 16.
    Wazny, J.: Type inference and type error diagnosis for Hindley/Milner with extensions. Ph.D. thesis, University of Melbourne (2006)Google Scholar
  17. 17.
    Winant, T., Devriese, D., Piessens, F., Schrijvers, T.: Partial type signatures for Haskell: Extended version with proofs of the theorems. Tech. Rep. 649, Department of Computer Science, KU Leuven (November 2013), http://www.cs.kuleuven.be/publicaties/rapporten/cw/CW649.abs.html
  18. 18.
    Yorgey, B.A., Weirich, S., Cretin, J., Peyton Jones, S., Vytiniotis, D., Magalhães, J.P.: Giving haskell a promotion. In: TLDI, pp. 53–66 (2012)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Thomas Winant
    • 1
  • Dominique Devriese
    • 1
  • Frank Piessens
    • 1
  • Tom Schrijvers
    • 2
  1. 1.KU LeuvenLeuvenBelgium
  2. 2.Ghent UniversityGentBelgium

Personalised recommendations