skip to main content
research-article

Improving Haskell types with SMT

Published:30 August 2015Publication History
Skip Abstract Section

Abstract

We present a technique for integrating GHC's type-checker with an SMT solver. The technique was developed to add support for reasoning about type-level functions on natural numbers, and so our implementation uses the theory of linear arithmetic. However, the approach is not limited to this theory, and makes it possible to experiment with other external decision procedures, such as reasoning about type-level booleans, bit-vectors, or any other theory supported by SMT solvers.

References

  1. Yices Manual, 2015. URL http://yices.csl.sri.com/papers/ manual.pdf.Google ScholarGoogle Scholar
  2. Adam Gundry. A typechecker plugin for units of measure. Submitted for publication., 2015.Google ScholarGoogle Scholar
  3. Christiaan Baaij. A plug-in for normalising type literals in ghc. 2015. URL https://github.com/clash-lang/ ghc-typelits-natnormalise.Google ScholarGoogle Scholar
  4. Clark Barrett, Aaron Stump, and Cesare Tinelli. The SMT-LIB standard: Version 2.0. Technical report, Department of Computer Science, The University of Iowa, 2010. URL http://smtlib.cs. uiowa.edu/papers/smt-lib-reference-v2.0-r12.09.09.pdf.Google ScholarGoogle Scholar
  5. Clark Barrett, Christopher L. Conway, Morgan Deters, Liana Hadarean, Dejan Jovanovi´c, Tim King, Andrew Reynolds, and Cesare Tinelli. CVC4. In Proceedings of the 23rd International Conference on Computer Aided Verification, Snowbird, Utah, USA, 2011. URL http://dl.acm.org/citation.cfm?id=2032305.2032319.Google ScholarGoogle Scholar
  6. Dimitrios Vytiniotis and Simon Peyton Jones. Evidence normalization in System FC. In 24th International Conference on Rewriting Techniques and Applications, Eindhoven, Netherlands, 2013. URL http://research.microsoft.com/en-us/um/people/simonpj/ papers/ext-f/fc-new-tyco.pdf.Google ScholarGoogle Scholar
  7. Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. OutsideIn(X): Modular type inference with local assumptions. Journal of Functional Programming, September 2011. URL http://research.microsoft.com/apps/pubs/default. aspx?id=162516. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Greg Nelson and Derek C. Oppen. Simplification by cooperating decision procedures. ACM Transactions on Programming Languages and Systems, 1(2), October 1979. URL http://doi.acm.org/10. 1145/357073.357079. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Iavor S. Diatchki. simple-smt: a Haskell library for working with SMT solvers, 2015. URL http://hackage.haskell.org/package/ simple-smt.Google ScholarGoogle Scholar
  10. Iavor S. Diatchki. A plug-in for solving linear constraints using an smt solver. 2015. URL https://github.com/yav/type-nat-solver.Google ScholarGoogle Scholar
  11. J. Garrett Morris and Mark P. Jones. Instance chains: Type class programming without overlapping instances. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP ’10), Baltimore, Maryland, USA, 2010. URL http://web.cecs.pdx.edu/~mpj/pubs/instancechains.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Leonardo de Moura and Nikolaj Bjørner. Z3: An efficient smt solver. In Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, Budapest, Hungary, 2008. URL http://research.microsoft.com/projects/z3/z3.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Mark P. Jones. Simplifying and improving qualified types. In FPCA ’95: Conference on Functional Programming Languages and Computer Architecture, La Jolla, California, USA, 1995. URL http://web.cecs.pdx.edu/~mpj/pubs/fpca95.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-jones. Refinment types for Haskell. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming, Gothenburg, Sweeden, 2014. URL http://goto. ucsd.edu/~rjhala/papers/refinement_types_for_haskell. pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Patrick C. Hickey, Lee Pike, Trevor Elliott, James Bielman, and John Launchbury. Building embedded systems with embedded DSLs (experience report). In Proceedings of the 2014 ACM SIGPLAN Conference on Functional Programming, Gothenburg, Sweden, 2014. URL https: //github.com/GaloisInc/smaccmpilot-experiencereport/ blob/master/embedded-experience.pdf?raw=true. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Richard A. Eisenberg and Jan Stolarek. Promoting functions to type families in Haskell. In Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, Gothenburg, Sweden, 2014. URL http://www.cis.upenn.edu/~eir/papers/2014/promotion/ promotion.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Richard A. Eisenberg and Stephanie Weirich. Dependently typed programming with singletons. In Proceedings of the 2012 ACM SIGPLAN Symposium on Haskell, Copenhagen, Denmark, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Sam Lindley and Conor McBride. Hasochism: The pleasure and pain of dependently typed Haskell programming. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell, Boston, Massachusetts, USA, 2013. URL https://personal.cis.strath.ac.uk/conor. mcbride/pub/hasochism.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Sergey Berezin, Vijay Ganesh, and Daivd L. Dill. An online proofproducing decision procedure for mixed-integer linear arithmetic. In Proceedings of the 9th International Conference on Tools and Algorithms for the Construction and Analysis of Systems, Warsaw, Poland, 2003. URL http://hci.stanford.edu/cstr/reports/2007-07.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. The GHC Team. The Glorious Glasgow Haskell Compilation System User’s Guide, Version 7.10.1, 2015. URL https://downloads. haskell.org/~ghc/7.10.1/docs/html/users_guide/index. html.Google ScholarGoogle Scholar

Index Terms

  1. Improving Haskell types with SMT

    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 50, Issue 12
      Haskell '15
      December 2015
      212 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2887747
      Issue’s Table of Contents
      • cover image ACM Conferences
        Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell
        August 2015
        212 pages
        ISBN:9781450338080
        DOI:10.1145/2804302

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 30 August 2015

      Check for updates

      Qualifiers

      • research-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!