skip to main content
10.1145/317636.317781acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article
Free Access

From fast exponentiation to square matrices: an adventure in types

Published:01 September 1999Publication History

ABSTRACT

Square matrices serve as an interesting case study in functional programming. Common representations, such as lists of lists, are both inefficient---at least for access to individual elements---and error-prone, because the compiler cannot enforce "squareness". Switching to a typical balanced-tree representation solves the first problem, but not the second. We develop a representation that solves both problems: it offers logarithmic access to each individual element and it captures the shape invariants in the type, where they can be checked by the compiler. One interesting feature of our solution is that it translates the well-known fast exponentiation algorithm to the level of types. Our implementation also provides a stress test for today's advanced type systems---it uses nested types, polymorphic recursion, higher-order kinds, and rank-2 polymorphism.

References

  1. 1.Richard S. Bird and Lambert Meertens. Nested datatypes. In Conference on Mathematics of Program Construction, volume 1422 of LNCS, June 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2.Richard S. Bird and Ross Paterson. de Bruijn notation as a nested datatype. Journal of Functional Programming, To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 3.F. Warren Burton and John G. Kollias. Functional programming with quadtrees. IEEE Software, 6(1):90- 97, January 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 4.Jeremy D. Frens and David S. Wise. Matrix inversion using quadtrees implemented in gofer. Technical Report 433, Computer Science Department, Indiana University, May 1995.Google ScholarGoogle Scholar
  5. 5.Fritz Henglein. Type inference with polymorphic recursion. A CM Transactions on Programming Languages and Systems, 15(2):253-289, April 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 6.Ratf Hinze. Polytypic functions over nested datatypes (extended abstract). In Latin-American Conference on Functional Programming, March 1999.Google ScholarGoogle Scholar
  7. 7.Anne KaJdewaij and Victor J. Dielissen. Leaf trees. Science of Computer Programming, 26(1-3): 149-165, May 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8.Chris Okasaki. Purely Functional Data Structures. Cambridge University Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9.Simon Peyton Jones et al. Haskell 98: A non-strict, purely functional language. http://haskell, org/onlinereport/, February 1999.Google ScholarGoogle Scholar
  10. 10.Hanan Samet. The quadtree and related hierarchical data structures. A CM Computing Surveys, 16(2):187- 260, June 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11.David S. Wise. Matrix algorithms using quadtrees. Technical Report 357, Computer Science Department, Indiana University, June 1992.Google ScholarGoogle Scholar

Index Terms

  1. From fast exponentiation to square matrices: an adventure in types

        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
        • Published in

          cover image ACM Conferences
          ICFP '99: Proceedings of the fourth ACM SIGPLAN international conference on Functional programming
          September 1999
          288 pages
          ISBN:1581131119
          DOI:10.1145/317636
          • Chairmen:
          • Didier Rémy,
          • Peter Lee

          Copyright © 1999 ACM

          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]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 September 1999

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • Article

          Acceptance Rates

          ICFP '99 Paper Acceptance Rate25of81submissions,31%Overall Acceptance Rate333of1,064submissions,31%

          Upcoming Conference

          ICFP '24

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader