Skip to main content

Type Class Instances for Type-Level Lambdas in Haskell

  • Conference paper
  • First Online:
  • 515 Accesses

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9547))

Abstract

Haskell 2010 lacks flexibility in creating instances of type classes for type constructors with multiple type arguments. We would like to make the order of type arguments to a type constructor irrelevant to how type class instances can be specified. None of the currently available techniques in Haskell allows to do this in a satisfactory way.

To flexibly create type-class instances we have added the concept of type-level lambdas as anonymous type synonyms to Haskell. As higher-order unification of lambda terms in general is undecidable, we take a conservative approach to equality between type-level lambdas. We propose a number of small changes to the constraint solver that will allow type-level lambdas to be used in type class instances. We show that this satisfies our goal, while having only minor impact on existing Haskell code.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  1. Alkemade, T.P.: UnitTyped (2012). https://hackage.haskell.org/package/unittyped. Accessed 9 Apr 2014

  2. Chakravarty, M.M.T., Keller, G., Jones, S.P., Marlow, S.: Associated types with class. In: Proceedings of POPL 2005: The 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–13. ACM (2005)

    Google Scholar 

  3. Elliott, C.: TypeCompose (2007–2013). https://hackage.haskell.org/package/TypeCompose. Accessed 10 Dec 2013

  4. Gill, A., Paterson, R.: Transformers (2009–2012). Accessed 10 Dec 2013

    Google Scholar 

  5. Hall, C., Hammond, K., Jones, S.P., Wadler, P.: Type classes in haskell. ACM Trans. Program. Lang. Syst. 18, 241–256 (1996)

    Article  Google Scholar 

  6. Huet, G.P.: The undecidability of unification in third order logic. Inf. Control 22(3), 257–267 (1973)

    Article  MathSciNet  MATH  Google Scholar 

  7. Kmett, E.A.: Bifunctors (2011–2013). https://hackage.haskell.org/package/bifunctors. Accessed 10 Dec 2013

  8. Marlow, S.: Haskell 2010 language report (2010). https://www.haskell.org/onlinereport/haskell2010/

  9. Neubauer, M., Thiemann, P.: Type classes with more higher-order polymorphism. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP 2002, pp. 179–190. ACM, New York (2002)

    Google Scholar 

  10. Peterson, J., Jones, M.: Implementing type classes. In: Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation, PLDI 1993, pp. 227–236. ACM, New York (1993)

    Google Scholar 

  11. The GHC Team: The Glorious Glasgow Haskell Compilation System User’s Guide. http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/index.html

  12. Vytiniotis, D., Jones, S.P., Schrijvers, T., Sulzmann, M.: OutsideIn(X) Modular type inference with local assumptions. J. Funct. Program. 21(4–5), 333–412 (2011)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgments

We would like to thank the anonymous reviewers for their extensive comments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Thijs Alkemade .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Alkemade, T., Jeuring, J. (2016). Type Class Instances for Type-Level Lambdas in Haskell. In: Serrano, M., Hage, J. (eds) Trends in Functional Programming. TFP 2015. Lecture Notes in Computer Science(), vol 9547. Springer, Cham. https://doi.org/10.1007/978-3-319-39110-6_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-39110-6_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-39109-0

  • Online ISBN: 978-3-319-39110-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics