In his seminal paper “Why functional programming matters”, John Hughes argues that the strength of lazy, higher order languages lies in the ability to glue different functions of a program together. In this thesis we explore how these languages are suited to glue not only functions but also software components written in different languages.

The first chapter of this thesis describes the design of a foreign function interface for the non-strict, higher order language Haskell. A foreign function interfaces (FFI) enables a program to call programs written in other languages and vice versa.  different languages can use different calling conventions and data representations { the foreign language interface ensures a proper calling convention and transforms data values into the representation of the foreign language. The transformation of data values to their foreign representation, called marshalling, is where most complications arise.