Inferring Type Isomorphisms Generically

  • Frank Atanassow
  • Johan Jeuring
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3125)

Abstract

Datatypes which differ inessentially in their names and structure are said to be isomorphic; for example, a ternary product is isomorphic to a nested pair of binary products. In some canonical cases, the conversion function is uniquely determined solely by the two types involved. In this article we describe and implement a program in Generic Haskell which automatically infers this function by normalizing types w.r.t. an algebraic theory of canonical isomorphisms. A simple generalization of this technique also allows to infer some non-invertible coercions such as projections, injections and ad hoc coercions between base types. We explain how this technique has been used to drastically improve the usability of a Haskell–XML Schema data binding, and suggest how it might be applied to improve other type-safe language embeddings.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Atanassow, F., Clarke, D., Jeuring, J.: Scripting XML with Generic Haskell. In: Proc. 7th Brazilian Symposium on Programming Languages (2003), See also Utrecht University technical report UU-CS-2003Google Scholar
  2. 2.
    Balat, V., Di Cosmo, R.: A linear logical view of linear type isomorphisms. In: CSL, pp. 250–265 (1999)Google Scholar
  3. 3.
    Beylin, I., Dybjer, P.: Extracting a proof of coherence for monoidal categories from a proof of normalization for monoids. In: TYPES, pp. 47–61 (1995)Google Scholar
  4. 4.
    Brown, A., Fuchs, M., Robie, J., Wadler, P.: MSL: A model for W3C XML Schema. In: Proc. WWW10 (May 2001)Google Scholar
  5. 5.
    Bruce, K.B., Di Cosmo, R., Longo, G.: Provable isomorphisms of types. Mathematical Structures in Computer Science 2(2), 231–247 (1992)MATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Cluet, S., Siméon, J.: YATL: a functional and declarative language for XML (2000)Google Scholar
  7. 7.
    Coelho, J., Florido, M.: Type-based XML processing in logic programming. In: PADL 2003, pp. 273–285 (2003)Google Scholar
  8. 8.
    Di Cosmo, R.: Isomorphisms of Types: From lambda-calculus to Information Retrieval and Language Design. Birkhäuser, Basel (1995)MATHGoogle Scholar
  9. 9.
    Gapeyev, V., Pierce, B.C.: Regular object types. In: European Conference on Object-oriented Programming, ECOOP 2003 (2003)Google Scholar
  10. 10.
    Hermida, C.: Representable multicategories. Advances in Mathematics 151, 164–225 (2000)MATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Hinze, R., Jeuring, J., Löh, A.: Type-indexed data types. In: Boiten, E.A., Möller, B. (eds.) MPC 2002. LNCS, vol. 2386, pp. 148–174. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  12. 12.
    Hosoya, H., Pierce, B.C.: XDuce: A typed XML processing language. In: Suciu, D., Vossen, G. (eds.) WebDB 2000. LNCS, vol. 1997, pp. 226–244. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  13. 13.
    Kiselyov, O., Krishnamurti, S.: SXSLT: manipulation language for XML. In: PADL 2003, pp. 226–272 (2003)Google Scholar
  14. 14.
    Leinster, T.S.H.: Operads in Higher-Dimensional Category Theory. PhD thesis, Trinity College and St John’s College, Cambridge (2000) Google Scholar
  15. 15.
    Leinster, T.: Higher Operads, Higher Categories. Cambridge University Press, Cambridge (2003)Google Scholar
  16. 16.
    Leroy, X., et al.: The Objective Caml system release 3.07, Documentation and user’s manual (December 2003), Available from http://caml.inria.fr/ocaml/htmlman/
  17. 17.
    Löh, A., Clarke, D., Jeuring, J.: Dependency-style Generic Haskell. In: Proceedings of the International Conference on Functional Programming (ICFP 2003) (August 2003)Google Scholar
  18. 18.
    Lane, S.M.: Natural associativity and commutativity. Rice University Studies 49, 28–46 (1963) Google Scholar
  19. 19.
    Lane, S.M.: Categories for the Working Mathematician, 2nd edn. Graduate Texts in Mathematics, vol. 5. Springer, New York (1997) (1st ed., 1971)Google Scholar
  20. 20.
    McAdam, B.: How to repair type errors automatically. In: Trends in Functional Programming (Proc. Scottish Functional Programming Workshop), vol. 3 (2001)Google Scholar
  21. 21.
    McLaughlin, B.: Java & XML data binding. O’Reilly, Sebastopol (2003)Google Scholar
  22. 22.
    Meijer, E., Shields, M.: XMLambda: A functional language for constructing and manipulating XML documents (1999), Available from http://www.cse.ogi.edu/~mbs/
  23. 23.
    Metz, E., Brookes, A.: XML data binding. Dr. Dobb’s Journal, 26–36 (March 2003)Google Scholar
  24. 24.
    Sun Microsystems. Java Architecture for XML Binding (JAXB). http://java.sun.com/xml/jaxb/ (2003)
  25. 25.
    Milner, R., Tofte, M., Harper, R., MacQueen, D.: The Definition of Standard ML (Revised). MIT Press, Cambridge (May 1997)Google Scholar
  26. 26.
    Ogbuji, U.: Xml data bindings in python, parts 1 & 2. xml.com (2003), http://www.xml.com/pub/a/2003/06/11/py-xml.html
  27. 27.
    Jones, S.P., Hughes, J., et al.: Haskell 98 – A non-strict, purely functional language, Available from http://haskell.org (February 1999)
  28. 28.
    Rahm, E., Bernstein, P.A.: A survey of approaches to automatic schema matching. VLDB Journal: Very Large Data Bases 10(4), 334–350 (2001)MATHCrossRefGoogle Scholar
  29. 29.
    Rittri, M.: Retrieving library identifiers via equational matching of types. In: Conference on Automated Deduction, pp. 603–617 (1990)Google Scholar
  30. 30.
    Rittri, M.: Retrieving library functions by unifying types modulo linear isomorphism. Informatique Theorique et Applications 27(6), 523–540 (1993)MATHGoogle Scholar
  31. 31.
    Shields, M., Meijer, E.: Type-indexed rows. In: The 28th Annual ACM SIGPLAN - SIGACT Symposium on Principles of Programming Languages, pp. 261–275 (2001), Also available from http://www.cse.ogi.edu/~mbs/
  32. 32.
    Siméon, J., Wadler, P.: The essence of XML. In: Proc. POPL 2003 (2003)Google Scholar
  33. 33.
    Soloviev, S.: A complete axiom system for isomorphism of types in closed categories. In: Voronkov, A. (ed.) LPAR 1993. LNCS, vol. 698, pp. 360–371. Springer, Heidelberg (1993)Google Scholar
  34. 34.
    Thatte, S.R.: Coercive type isomorphism. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 29–49. Springer, Heidelberg (1991)Google Scholar
  35. 35.
    Thiemann, P.: A typed representation for HTML and XML documents in Haskell. Journal of Functional Programming 12(4&5), 435–468 (2002)MATHMathSciNetGoogle Scholar
  36. 36.
    W3C. XSL Transformations 1.0, http://www.w3.org/TR/xslt (1999)
  37. 37.
    Wallace, M., Runciman, C.: Haskell and XML: Generic combinators or type-based translation? In: International Conference on Functional Programming, pp. 148–159 (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Frank Atanassow
    • 1
  • Johan Jeuring
    • 1
  1. 1.Institute of Information & Computing SciencesUtrecht UniversityThe Netherlands

Personalised recommendations