Run Time Type Information in Mercury

  • Tyson Dowd
  • Zoltan Somogyi
  • Fergus Henderson
  • Thomas Conway
  • David Jeffery
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1702)


The logic/functional language Mercury uses a strong, mostly static type system based on polymorphic many-sorted logic. For efficiency, the Mercury compiler uses type specific representations of terms, and implements polymorphic operations such as unifications via generic code invoked with descriptions of the actual types of the operands. These descriptions, which consist of automatically generated data and code, are the main components of the Mercury runtime type information (RTTI) system. We have used this system to implement several extensions of the Mercury system, including an escape mechanism from static type checking, generic input and output facilities, a debugger, and automatic memoization, and we are in the process of using it for an accurate, native garbage collector. We give detailed information on the implementation and uses of the Mercury RTTI system as well as measurements of the space costs of the system.


Function Symbol Garbage Collection Type Info Native Collector 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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abadi, M., Cardelli, L., Pierce, B., Plotkin, G.: Dynamic typing in a statially typed language. ACM Transactions on Programming Languages and Systems 13(2), 237–268 (1991)CrossRefGoogle Scholar
  2. 2.
    Aditya, S., Caro, A.: Compiler-directed type reconstruction for polymorphic languages. In: Proceedings of the 1993 ACM Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark (June 1993)Google Scholar
  3. 3.
    Aditya, S., Flood, C., Hicks, J.: Garbage collection for strongly-typed languages using run-time type reconstruction. In: Proceedings of the 1994 ACM Conference on Lisp and Functional Programming, June 1994, pp. 12–23 (1994)Google Scholar
  4. 4.
    Beierle, C., Meyer, G., Semle, H.: Extending the warren abstract machine to polymorphic order-sorted resolution. In: Proceedings of the International Logic Programming Symposium, pp. 272–286 (1991)Google Scholar
  5. 5.
    Boehm, H., Weiser, M.: Garbage collection in an uncooperative environment. Software-Practice and Experience 18, 807–820 (1988)CrossRefGoogle Scholar
  6. 6.
    Demoen, B., de la Banda, M.G., Harvey, W., Marriott, K., Stuckey, P.: Herbrand constraint solving in HAL. Technical Report 99/18, Department of Software Engineering and Computer Science, University of Melbourne, Melbourne, Australia (1998)Google Scholar
  7. 7.
    Elsman, M.: Polymorphic equality–no tags required. In: Leroy, X., Ohori, A. (eds.) TIC 1998. LNCS, vol. 1473, pp. 136–155. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  8. 8.
    Goldberg, B.: Tag-free garbage collection for strongly typed programming languages. In: Proceedings of the SIGPLAN 1991 Conference on Programming Languages Design and Implementation, Toronto, Ontario, June 1991, pp. 165–176 (1991)Google Scholar
  9. 9.
    Hanson, D.R., Raghavachari, M.: A machine-independent debugger. Software – Practice and Experience 26, 1277–1299 (1996)CrossRefGoogle Scholar
  10. 10.
    Henderson, F., Conway, T., Somogyi, Z., Jeffery, D.: The Mercury language reference manual. Technical Report 96/10, Department of Computer Science, University of Melbourne, Melbourne, Australia (1996)Google Scholar
  11. 11.
    Kwon, K., Nadathur, G., Wilson, D.S.: Implementing polymorphic typing in a logic programming language. Computer Languages 20(1), 25–42 (1994)zbMATHCrossRefGoogle Scholar
  12. 12.
    Somogyi, Z., Henderson, F., Conway, T.: The execution algorithm of Mercury, an efficient purely declarative logic programming language. Journal of Logic Programming 26(1-3), 17–64 (1996)CrossRefGoogle Scholar
  13. 13.
    Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., Lee, P.: TIL: A type-directed optimizing compiler for ML. In: Proceedings of the SIGPLAN 1996 Conference on Programming Language Design and Implemantation, New York, May 21-24, pp. 181–192 (1996)Google Scholar
  14. 14.
    Tolmach, A.: Tag-free garbage collection using explicit type parameters. In: Proceedings of the SIGPLAN 1994 Conference on Programming Languages Design and Implementation, Orlando, Florida, June 1994, pp. 1–11 (1994)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1999

Authors and Affiliations

  • Tyson Dowd
    • 1
  • Zoltan Somogyi
    • 1
  • Fergus Henderson
    • 1
  • Thomas Conway
    • 1
  • David Jeffery
    • 1
  1. 1.Department of Computer Science and Software EngineeringUniversity of MelbourneParkvilleAustralia

Personalised recommendations