Skip to main content

Interfacing Haskell with Object-Oriented Languages

  • Conference paper
Implementation of Functional Languages (IFL 2003)

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

Included in the following conference series:

Abstract

The interfacing of object-oriented languages with functional languages, in general, and with Haskell, in particular, has received a considerable amount of attention. Previous work, including Lambada, a Haskell to Java bridge, showed how an object-oriented class hierarchy can be modeled using Haskell type classes, such that Java libraries can be used conveniently from Haskell.

The present paper extends this previous work in two major directions. Firstly, we describe a new implementation of object-oriented style method calls and overloading in Haskell, using multi-parameter type classes and functional dependencies. This enables calling of a foreign object’s methods in a syntactically convenient, type-safe manner. Secondly, we sketch an approach to automating the generation of library bindings using compile-time meta-programming for object-oriented frameworks featuring reflection. We have evaluated the practicality of our approach by implementing a Haskell binding to the Objective-C language on the Mac OS X platform.

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. Simon Peyton Jones, M.J., Meijer, E.: Type classes: exploring the design space. In: Haskell Workshop (1997)

    Google Scholar 

  2. Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  3. Sheard, T., Peyton Jones, S.: Template meta-programming for haskell. In: Proceedings of the Haskell Workshop (2002)

    Google Scholar 

  4. Meijer, E., Finne, S.: Lambada: Haskell as a better Java. Electronic Notes in Theoretical Computer Science 41(1) (2001)

    Google Scholar 

  5. Shields, M., Peyton Jones, S.: Object-oriented style overloading for Haskell. In: First Workshop on Multi-language Inferastructure and Interoperability (BABEL 2001), Firenze, Italy (2001)

    Google Scholar 

  6. Leijen, D., Meijer, E., Hook, J.: Haskell as an automation controller. In: Advanced Functional Programming, pp. 268–289 (1998)

    Google Scholar 

  7. Finne, S., Leijen, D., Meijer, E., Jones, S.P.: Calling hell from heaven and heaven from hell. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ACM Press, New York (1999)

    Google Scholar 

  8. Peyton Jones, S., Meijer, E., Leijen, D.: Scripting COM components in Haskell. In: Proceedings of the Fifth International Conference on Software Reuse, IEEE Computer Society, Los Alamitos (1998)

    Google Scholar 

  9. Finne, S., Leijen, D., Meijer, E., Peyton Jones, S.L.: H/Direct: A binary foreign language interface for Haskell. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 1998), pp. 153–162. ACM Press, New York (1998)

    Chapter  Google Scholar 

  10. Courtney, A.: GCJNI (2002), http://haskell.cs.yale.edu/gcjni/

  11. Yakeley, A.: Haskell/Java VM Bridge (2003), http://sourceforge.net/projects/jvm-bridge/

  12. Nordin, T., Peyton Jones, S.L., Reid, A.: Green Card: a foreign-language interface for Haskell. In: Proceedings of the Haskell Workshop (1997)

    Google Scholar 

  13. Chakravarty, M.M.T.: C→Haskell, or yet another interfacing tool. In: Koopman, P., Clack, C. (eds.) IFL 1999. LNCS, vol. 1868, Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  14. The GHC Team: The Glasgow Haskell Compiler user’s guide: Writing Haskell interfaces to C code: hsc2hs (2001), http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html

  15. Reid, A.: Template Greencard (draft). In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, Springer, Heidelberg (2004)

    Google Scholar 

  16. The Haskell FFI Team: A primitive foreign function interface (1998), http://www.cse.unsw.edu.au/~chak/haskell/ffi/

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Pang, A.T.H., Chakravarty, M.M.T. (2004). Interfacing Haskell with Object-Oriented Languages. In: Trinder, P., Michaelson, G.J., Peña, R. (eds) Implementation of Functional Languages. IFL 2003. Lecture Notes in Computer Science, vol 3145. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-27861-0_2

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-27861-0_2

  • Publisher Name: Springer, Berlin, Heidelberg

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

  • Online ISBN: 978-3-540-27861-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics