Skip to main content

Programming with Arrows

  • Conference paper
Advanced Functional Programming

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

Abstract

Consider this simple Haskell definition, of a function which counts the number of occurrences of a given word w in a string:

count w = length . filter (==w) . words

This is an example of “point-free” programming style, where we build a function by composing others, and make heavy use of higher-order functions such as filter. Point-free programming is rightly popular: used appropriately, it makes for concise and readable definitions, which are well suited to equational reasoning in the style of Bird and Meertens [2]. It’s also a natural way to assemble programs from components, and closely related to connecting programs via pipes in the UNIX shell.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Benton, N., Hyland, M.: Traced premonoidal categories. ITA 37(4), 273–299 (2003)

    MathSciNet  MATH  Google Scholar 

  2. Bird, R.S.: A calculus of functions for program derivation. In: Turner, D. (ed.) Research Topics in Functional Programming. Addison-Wesley, Reading (1990)

    Google Scholar 

  3. Carlsson, M., Hallgren, T.: FUDGETS - A graphical user interface in a lazy functional language. In: Proceedings of the ACM Conference on Functional Programming and Computer Architecture, Copenhagen. ACM, New York (1993)

    Google Scholar 

  4. Claessen, K., Hughes, J.: Quickcheck: A lightweight tool for random testing of Haskell programs. In: International Conference on Functional Programming (ICFP), ACM SIGPLAN (2000)

    Google Scholar 

  5. Courtney, A., Elliott, C.: Genuinely functional user interfaces. In: Haskell Workshop, Firenze, Italy, pp. 41–69 (2001)

    Google Scholar 

  6. Courtney, A., Nilsson, H., Paterson, R.: Arrows: A general interface to computation, http://www.haskell.org/arrows/

  7. English, J.: Hxml, http://www.flightlab.com/~joe/hxml/

  8. Hudak, P., Courtney, A., Nilsson, H., Peterson, J.: Arrows, robots, and functional reactive programming. In: Summer School on Advanced Functional Programming 2002, Oxford University. LNCS, vol. 2638, pp. 159–187. Springer, Heidelberg (2003)

    Google Scholar 

  9. Hughes, J.: Restricted Datatypes in Haskell. In: Third Haskell Workshop. Utrecht University technical report (1999)

    Google Scholar 

  10. Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37(1–3), 67–111 (2000)

    Article  MathSciNet  Google Scholar 

  11. Jansson, P., Jeuring, J.: Polytypic data conversion programs. Science of Computer Programming 43(1), 35–75 (2002)

    Article  MathSciNet  Google Scholar 

  12. Launchbury, J., Lewis, J.R., Cook, B.: On embedding a microarchitectural design language within Haskell. In: ICFP, Paris, pp. 60–69. ACM Press, New York (1999)

    Google Scholar 

  13. Liang, S., Hudak, P., Jones, M.P.: Monad transformers and modular interpreters. In: Symposium on Principles of Programming Languages, San Francisco, January 1995, ACM SIGPLAN-SIGACT (1995)

    Google Scholar 

  14. Moggi, E.: Computational lambda-calculus and monads. In: Proceedings 4th Annual IEEE Symp. on Logic in Computer Science, LICS 1989, Pacific Grove, CA, USA, June 5-8, 1989, pp. 14–23. IEEE Computer Society Press, Washington (1989)

    Google Scholar 

  15. Sheeran, M., Bjesse, P., Claessen, K., Singh, S.: Lava: Hardware design in Haskell. In: ICFP. ACM Press, New York (1998)

    Google Scholar 

  16. Paterson, R.: Arrow transformer library, http://www.haskell.org/arrows/download.html

  17. Paterson, R.: A new notation for arrows. In: ICFP, Firenze, Italy. ACM, New York (2001)

    Google Scholar 

  18. Paterson, R.: Arrows and computation. In: Gibbons, J., Moor, O.D. (eds.) The Fun of Programming. Palgrave (2003)

    Google Scholar 

  19. Achten, R.P.P., van Eekelen, M.: Arrows for generic graphical editor components. Technical Report NIII-R0416, Nijmegen Institute for Computing and Information Sciences, University of Nijmegen (2004)

    Google Scholar 

  20. Peyton-Jones, S., Washburn, G., Weirich, S.: Wobbly types: type inference for generalised algebraic data types (July 2004), http://research.microsoft.com/Users/simonpj/papers/gadt/index.htm

  21. Pierce, C.: Basic Category Theory for Computer Scientists. MIT Press, Cambridge (1991)

    Book  Google Scholar 

  22. Power, J., Robinson, E.: Premonoidal categories and notions of computation. Mathematical Structures in Computer Science 7(5), 453–468 (1997)

    Article  MathSciNet  Google Scholar 

  23. Power, J., Thielecke, H.: Closed Freyd- and κ-categories. In: Wiedermann, J., Van Emde Boas, P., Nielsen, M. (eds.) ICALP 1999. LNCS, vol. 1644, pp. 625–634. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  24. Swierstra, D.S., Duponcheel, L.: Deterministic, error-correcting combinator parsers. In: Launchbury, J., Meijer, E., Sheard, T. (eds.) Advanced Functional Programming. LNCS, vol. 1129, pp. 184–207. Springer, Heidelberg (1996)

    Chapter  Google Scholar 

  25. Thiemann, P.: WASH/CGI: Server-side web scripting with sessions and typed, compositional forms. In: Practical Aspects of Declarative Languages, pp. 192–208 (2002)

    Google Scholar 

  26. Wadler, P.L.: Comprehending monads. In: Proceedings of the 1990 ACM Conference on LISP and Functional Programming, Nice, pp. 61–78. ACM, New York (1990)

    Chapter  Google Scholar 

  27. Wallace, M., Runciman, C.: Haskell and XML: Generic combinators or type-based translation? In: International Conference on Functional Programming, pp. 148–159. ACM Press, New York (1999)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Hughes, J. (2005). Programming with Arrows. In: Vene, V., Uustalu, T. (eds) Advanced Functional Programming. Lecture Notes in Computer Science, vol 3622. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11546382_2

Download citation

  • DOI: https://doi.org/10.1007/11546382_2

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-28540-3

  • Online ISBN: 978-3-540-31872-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics