Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2364506.2364514acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Testing type class laws

Published: 13 September 2012 Publication History

Abstract

The specification of a class in Haskell often starts with stating, in comments, the laws that should be satisfied by methods defined in instances of the class, followed by the type of the methods of the class. This paper develops a framework that supports testing such class laws using QuickCheck. Our framework is a light-weight class law testing framework, which requires a limited amount of work per class law, and per datatype for which the class law is tested. We also show how to test class laws with partially-defined values. Using partially-defined values, we show that the standard lazy and strict implementations of the state monad do not satisfy the expected laws.

References

[1]
J.-P. Bernardy, P. Jansson, and K. Claessen. Testing polymorphic properties. In ESOP'10, volume 6012 of Lecture Notes in Computer Science, pages 125--144. Springer, 2010.
[2]
M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. In POPL'05, pages 1--13. ACM, 2005.
[3]
K. Claessen and J. Hughes. QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs. In ICFP'00, pages 286--279. ACM, 2000.
[4]
N. A. Danielsson and P. Jansson. Chasing bottoms: A case study in program verification in the presence of partial and infinite values. In MPC'04, volume 3125 of Lecture Notes in Computer Science, pages 85--109. Springer, 2004.
[5]
N. A. Danielsson, J. Hughes, P. Jansson, and J. Gibbons. Fast and loose reasoning is morally correct. In POPL'06, pages 206--217. ACM, 2006.
[6]
C. Elliott. Checkers. A Haskell package available on Hackage, 2012. URL http://hackage.haskell.org/package/checkers-0.2.9.
[7]
J. Gibbons and R. Hinze. Just do it: simple monadic equational reasoning. In ICFP'11, pages 2--14. ACM, 2011.
[8]
P. Jansson and J. Jeuring. Polytypic data conversion programs. Science of Computer Programming, 43 (1): 35--75, 2002.
[9]
S. Marlow, editor. Haskell 2010 Language Report, 2010. http://www.haskell.org/onlinereport/haskell2010/.
[10]
C. Runciman, M. Naylor, and F. Lindblad. Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In Haskell'08, pages 37--48. ACM, 2008.
[11]
W. Taysom. Quickchecking type class laws. Blog post, 2011. URL http://www.cubiclemuses.com/cm/articles/2011/07/14/quickchecking-type-class-laws/.

Cited By

View all

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
Haskell '12: Proceedings of the 2012 Haskell Symposium
September 2012
168 pages
ISBN:9781450315746
DOI:10.1145/2364506
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 47, Issue 12
    Haskell '12
    December 2012
    157 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2430532
    Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 13 September 2012

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. classes
  2. laws
  3. state monad
  4. testing

Qualifiers

  • Research-article

Conference

ICFP'12
Sponsor:

Acceptance Rates

Overall Acceptance Rate 57 of 143 submissions, 40%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)2
  • Downloads (Last 6 weeks)0
Reflects downloads up to 17 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2021)Haskell⁻¹: automatic function inversion in HaskellProceedings of the 14th ACM SIGPLAN International Symposium on Haskell10.1145/3471874.3472982(41-55)Online publication date: 18-Aug-2021
  • (2021)Extensional equality preservation and verified generic programmingJournal of Functional Programming10.1017/S095679682100020431Online publication date: 21-Oct-2021
  • (2019)Effect Polymorphism in Higher-Order Logic (Proof Pearl)Journal of Automated Reasoning10.1007/s10817-018-9476-263:2(439-462)Online publication date: 1-Aug-2019
  • (2019)Proving Type Class Laws for HaskellMicrobial Metabolic Engineering10.1007/978-3-030-14805-8_4(61-74)Online publication date: 21-Feb-2019
  • (2017)Effect Polymorphism in Higher-Order Logic (Proof Pearl)Interactive Theorem Proving10.1007/978-3-319-66107-0_25(389-409)Online publication date: 2017
  • (2015)Reasoning with the HERMIT: tool support for equational reasoning on GHC core programsACM SIGPLAN Notices10.1145/2887747.280430350:12(23-34)Online publication date: 30-Aug-2015
  • (2015)Reasoning with the HERMIT: tool support for equational reasoning on GHC core programsProceedings of the 2015 ACM SIGPLAN Symposium on Haskell10.1145/2804302.2804303(23-34)Online publication date: 30-Aug-2015
  • (2013)Random testing of purely functional abstract datatypesProceedings of the 15th Symposium on Principles and Practice of Declarative Programming10.1145/2505879.2505880(275-284)Online publication date: 16-Sep-2013
  • (2024)Cooperative Specification via Composition ControlProceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3687997.3695635(2-15)Online publication date: 17-Oct-2024
  • (2019)Verifying effectful Haskell programs in CoqProceedings of the 12th ACM SIGPLAN International Symposium on Haskell10.1145/3331545.3342592(125-138)Online publication date: 8-Aug-2019

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media