Skip to main content

When Generic Functions Use Dynamic Values

  • Conference paper
  • First Online:
Implementation of Functional Languages (IFL 2002)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2670))

Included in the following conference series:

Abstract

Dynamic types allow strongly typed programs to link in external code at run-time in a type safe way. Generic programming allows programmers to write code schemes that can be specialized at compiletime to arguments of arbitrary type. Both techniques have been investigated and incorporated in the pure functional programming language Clean. Because generic functions work on all types and values, they are the perfect tool when manipulating dynamic values. But generics rely on compile-time specialization, whereas dynamics rely on run-time type checking and linking. This seems to be a fundamental contradiction. In this paper we show that the contradiction does not exist. From any generic function we derive a function that works on dynamics, and that can be parameterized with a dynamic type representation. Programs that use this technique combine the best of both worlds: they have concise universal code that can be applied to any dynamic value regardless of its origin. This technique is important for application domains such as type-safe mobile code and plug-in architectures.

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. Achten, P. and Hinze, R. Combining Generics and Dynamics. Technical Report NIII-R0206, July, 2002, Nijmegen Institute for Computing and Information Sciences, Faculty of Sciences, University of Nijmegen, The Netherlands.

    Google Scholar 

  2. Achten, P.M. and Wierich, M. A Tutorial to the Clean Object I/O Library-version 1.2. Technical Report CSI-R0003, February 2, 2000, Computing Science Institute, Faculty of Mathematics and Informatics, University of Nijmegen, The Netherlands.

    Google Scholar 

  3. Alimarine, A. and Plasmeijer, M. A Generic Programming Extension for Clean. In Arts, Th., Mohnen M., eds. Proceedings of 13th International Workshop on the Implementation of Functional Languages (IFL2001), Selected Papers, Älvsjö, Sweden, September 24–26, 2001, Springer-Verlag, LNCS 2312, pp.168–185.

    Chapter  Google Scholar 

  4. Altenkirch, T. and McBride, C. Generic Programming Within Dependently Typed Programming. To appear in Proceedings Working Conference on Generic Programming, Dagstuhl, Castle, Germany, July 11–12, 2002.

    Google Scholar 

  5. Brus, T., Eekelen, M.C.J.D. van, Leer, M.O. van, and Plasmeijer, M.J. Clean: A Language for Functional Graph Rewriting. In Kahn. G. ed. Proceedings of the Third International Conference on Functional Programming Languages and Computer Architecture, Portland, Oregon, USA, LNCS 274, Springer-Verlag, pp. 364–384.

    Google Scholar 

  6. Cheney, J. and Hinze, R. A Lightweight Implementation of Generics and Dynamics. In Chakravarty, M., ed. Proceedings of the ACM SIGPLAN 2002 Haskell Workshop, Pittsburgh, PA, USA, October 3, 2002, pp. 90–104.

    Google Scholar 

  7. Hinze, R. Polytypic values possess polykinded types. In Backhouse, R., Oliveira, J.N., eds. Proceedings of the Fifth International Conference on Mathematics of Program Construction (MPC 2000), July 3–5, 2000, LNCS 1837, Springer-Verlag, pp. 2–27.

    Google Scholar 

  8. Hinze, R. and Peyton Jones, S. Derivable Type Classes. In Graham Hutton, ed., Proceedings of the Fourth Haskell Workshop, Montreal, Canada, September 17, 2000.

    Google Scholar 

  9. Hinze, R. Generic Programming and Proofs. Habilitationsshrift, Universität Bonn, 2000.

    Google Scholar 

  10. Nöcker, E.G.J.M.H., Smetsers, J.E.W., Eekelen, M.C.J.D. van, and Plasmeijer, M.J. Concurrent Clean. In Aarts, E.H.L., Leeuwen, J. van, Rem, M., eds., Proceedings of Parallel Architectures and Languages Europe, June, Eindhoven, The Netherlands. LNCS 506, Springer-Verlag, pp. 202–219.

    Google Scholar 

  11. Pil, M.R.C., Dynamic types and type dependent functions. In Hammond, Davie, Clack, eds., Proc. of Implementation of Functional Languages (IFL’ 98), London, U.K., Springer-Verlag, Berlin, LNCS 1595, pp.169–185.

    Google Scholar 

  12. Pil, M. First Class File I/O, PhD Thesis, in preparation.

    Google Scholar 

  13. Plasmeijer, M.J. and van Eekelen, M.C.J.D. Functional Programming and Parallel Graph Rewriting, Addison-Wesley Publishing Company, 1993.

    Google Scholar 

  14. Vervoort, M. and Plasmeijer, R. Lazy Dynamic Input/Output in the lazy functional language Clean. In Peña, R. ed. Proc. of the 14th International Workshop on the Implementation of Functional Languages (IFL 2002), Madrid, Spain, September 16–18 2002, Technical Report 127-02, Departamento de Sistemas Informáticos y Programación, Universidad Complutense de Madrid, pp. 404–408.

    Google Scholar 

  15. van Weelden, A. and Plasmeijer, R. Towards a Strongly Typed Functional Operating System. In Peña, R. ed. Proc. of the 14th International Workshop on the Implementation of Functional Languages (IFL 2002), Madrid, Spain, September 16–18 2002, Technical Report 127-02, Departamento de Sistemas Informáticos y Programación, Universidad Complutense de Madrid, pp. 301–319.

    Google Scholar 

  16. Wadler, Ph. Comprehending monads. In Proceedings of the ACM Conference on Lisp and Functional Programming, Nice, 1990, ACM Press, pp. 61–78.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2001 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Achten, P., Alimarine, A., Plasmeijer, R. (2001). When Generic Functions Use Dynamic Values. In: Peña, R., Arts, T. (eds) Implementation of Functional Languages. IFL 2002. Lecture Notes in Computer Science, vol 2670. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44854-3_2

Download citation

  • DOI: https://doi.org/10.1007/3-540-44854-3_2

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-40190-2

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

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics