Advertisement

When Generic Functions Use Dynamic Values

  • Peter Achten
  • Artem Alimarine
  • Rinus Plasmeijer
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2670)

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.

Keywords

Type Representation Conversion Function Functional Language Dynamic Type Type Constructor 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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. 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. 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.CrossRefGoogle Scholar
  4. 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. 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. 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. 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. 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. 9.
    Hinze, R. Generic Programming and Proofs. Habilitationsshrift, Universität Bonn, 2000.Google Scholar
  10. 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. 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. 12.
    Pil, M. First Class File I/O, PhD Thesis, in preparation.Google Scholar
  13. 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. 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. 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. 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

Copyright information

© Springer-Verlag Berlin Heidelberg 2001

Authors and Affiliations

  • Peter Achten
    • 1
  • Artem Alimarine
    • 1
  • Rinus Plasmeijer
    • 1
  1. 1.Computing Science DepartmentUniversity of NijmegenNijmegenThe Netherlands

Personalised recommendations