Interfacing Haskell with Object-Oriented Languages

  • André T. H. Pang
  • Manuel M. T. Chakravarty
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3145)


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.


Class Object Type Class Class Hierarchy Interface Generator Method Invocation 
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.
    Simon Peyton Jones, M.J., Meijer, E.: Type classes: exploring the design space. In: Haskell Workshop (1997)Google Scholar
  2. 2.
    Jones, M.P.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  3. 3.
    Sheard, T., Peyton Jones, S.: Template meta-programming for haskell. In: Proceedings of the Haskell Workshop (2002)Google Scholar
  4. 4.
    Meijer, E., Finne, S.: Lambada: Haskell as a better Java. Electronic Notes in Theoretical Computer Science 41(1) (2001)Google Scholar
  5. 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. 6.
    Leijen, D., Meijer, E., Hook, J.: Haskell as an automation controller. In: Advanced Functional Programming, pp. 268–289 (1998)Google Scholar
  7. 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. 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. 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)CrossRefGoogle Scholar
  10. 10.
    Courtney, A.: GCJNI (2002),
  11. 11.
    Yakeley, A.: Haskell/Java VM Bridge (2003),
  12. 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. 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)CrossRefGoogle Scholar
  14. 14.
    The GHC Team: The Glasgow Haskell Compiler user’s guide: Writing Haskell interfaces to C code: hsc2hs (2001),
  15. 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. 16.
    The Haskell FFI Team: A primitive foreign function interface (1998),

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • André T. H. Pang
    • 1
    • 2
  • Manuel M. T. Chakravarty
    • 1
    • 3
  1. 1.School of Computer Science & EngineeringUniversity of New South WalesSydneyAustralia
  2. 2.CSIRO, Information & Communication Technologies 
  3. 3.National ICT Australia, ERTOS 

Personalised recommendations