Personal tools

Applications and libraries/Interfacing other languages

From HaskellWiki

< Applications and libraries(Difference between revisions)
Jump to: navigation, search
(+lambada)
(Others: add link to hR)
(23 intermediate revisions by 14 users not shown)
Line 4: Line 4:
 
== Tools for interfacing with other languages ==
 
== Tools for interfacing with other languages ==
   
The definition of a basic [http://www.cse.unsw.edu.au/~chak/haskell/ffi/ foreign function interface for Haskell (FFI)] is finished. It has been agreed on and
+
Haskell builtin features for interfacing to other languages are formally defined in the
implemented by most Haskell implementors. The following tools already
+
[http://www.cse.unsw.edu.au/~chak/haskell/ffi/ Foreign Function Interface (FFI)]. You may learn it by example at the
produce code for this interface. The [http://www.reid-consulting-uk.ltd.uk/docs/ffi.html Guide to Haskell's Foreign Function Interface] provides a comparision of the different tools.
+
[http://haskell.org/haskellwiki/IO_inside#Interfacing_with_C.2FC.2B.2B_and_foreign_libraries_.28under_development.29 IO inside] guide.
   
 
See also [[RPC | Web services and RPC]].
 
See also [[RPC | Web services and RPC]].
  +
  +
The following tools and libraries either simplify interfacing to C or allow interfacing to other languages and environments (COM, JVM, Python, Tcl, Lua...).
   
 
=== C ===
 
=== C ===
 
;[http://haskell.org/greencard/ Green Card]</dt>
 
: Green Card is a foreign function interface preprocessor for Haskell, simplifying the task of interfacing Haskell programs to external libraries (which are normally exposed via C interfaces). Green Card is currently able to generate code compatible with the [[Implementations#GHC_the_Glasgow_Haskell_Compiler | Glasgow Haskell Compiler]], [[Implementations#The_Haskell_Interpreter_Hugs| Hugs]] and [[Implementations#nhc98 | nhc]].
 
 
;[http://haskell.org/hdirect/ HaskellDirect]
 
:HaskellDirect is an Interface Definition Language (IDL) compiler for Haskell, which helps interfacing Haskell code to libraries or components written in other languages (C). An IDL specification specifies the type signatures and types expected by a set of external functions. One important use of this language neutral specification of interfaces is to specify COM (Microsoft's Component Object Model) interfaces, and HaskellDirect offers special support for both using COM objects from Haskell and creating Haskell COM objects. HaskellDirect groks both the OSF DCE dialect of IDL (including the various extensions introduced by the Microsoft IDL compiler) and the OMG IIOP/CORBA dialect.
 
   
 
;[http://www.cse.unsw.edu.au/~chak/haskell/c2hs/ C-&gt;Haskell]
 
;[http://www.cse.unsw.edu.au/~chak/haskell/c2hs/ C-&gt;Haskell]
 
:A lightweight tool for implementing access to C libraries from Haskell.
 
:A lightweight tool for implementing access to C libraries from Haskell.
   
;[http://hsffig.sourceforge.net HSFFIG]
+
;[http://hackage.haskell.org/package/c2hsc/ c2hsc]
  +
:A tool to create Bindings-DSL based interface files for C libraries.
  +
  +
;[[HSFFIG]]
 
:Haskell FFI Binding Modules Generator (HSFFIG) is a tool that takes a C library include file (.h) and generates Haskell Foreign Functions Interface import declarations for items (functions, structures, etc.) the header defines.
 
:Haskell FFI Binding Modules Generator (HSFFIG) is a tool that takes a C library include file (.h) and generates Haskell Foreign Functions Interface import declarations for items (functions, structures, etc.) the header defines.
   
 
;[http://www.astercity.net/~khaliff/haskell/kdirect/index.html KDirect]
 
;[http://www.astercity.net/~khaliff/haskell/kdirect/index.html KDirect]
 
:A tool to simplify the process of interfacing C libraries to Haskell. It is less powerful than HaskellDirect, but easier to use and more portable.
 
:A tool to simplify the process of interfacing C libraries to Haskell. It is less powerful than HaskellDirect, but easier to use and more portable.
  +
  +
;[http://hackage.haskell.org/cgi-bin/hackage-scripts/package/libffi libffi]
  +
:A binding to libffi, allowing C functions of types only known at runtime to be called from Haskell.
   
 
=== Java ===
 
=== Java ===
   
;[http://www.haskell.org/gcjni GCJNI]
+
See [http://www.haskell.org/pipermail/haskell-cafe/2013-May/108299.html the discussion on Haskell Cafe].
:A Java Native Interface for Haskell. Allows Haskell to invoke Java code. Includes a tool to generate Haskell bindings for a Java library. Works for hugs and ghc under both Linux and Windows.
 
 
;[http://sourceforge.net/projects/jvm-bridge/ Haskell/Java VM Bridge]
 
:A bridge to the Java virtual machine via JNI for Haskell.
 
 
;[http://www.dcs.gla.ac.uk/fp/software/hdirect Lambada]
 
:A Haskell <=> Java interoperation bridge. Interoperation between Haskell and Java is provided by Lambada via the Java Native Interface (JNI), giving you a set of Haskell abstractions that lets you both call out to Java from Haskell *and* wrap up Haskell code behind a Java-callable veneer.
 
   
 
=== Python ===
 
=== Python ===
Line 37: Line 36:
   
 
=== Others ===
 
=== Others ===
  +
  +
; [https://github.com/wavewave/fficxx fficxx]
  +
: A Haskell-C++ Foreign Function Interface Generator
   
 
;[http://web.archive.org/web/20010306205042/http://www.numeric-quest.com/haskell/smartest.html Smarty]
 
;[http://web.archive.org/web/20010306205042/http://www.numeric-quest.com/haskell/smartest.html Smarty]
Line 49: Line 51:
 
;[http://www.cse.unsw.edu.au/~dons/haskell-1990-2000/msg04613.html TclHaskell]
 
;[http://www.cse.unsw.edu.au/~dons/haskell-1990-2000/msg04613.html TclHaskell]
 
:TclHaskell is a haskell binding to Tcl-Tk that lets you build GUIs in Haskell. It is Haskell98 compliant. It has been tested under hugs98 and ghc-4.04.
 
:TclHaskell is a haskell binding to Tcl-Tk that lets you build GUIs in Haskell. It is Haskell98 compliant. It has been tested under hugs98 and ghc-4.04.
  +
  +
;[[CPlusPlusFromHaskell]]
  +
:A hackish method calling C++ from Haskell.
  +
  +
;[http://www.mail-archive.com/haskell@haskell.org/msg20614.html Re: &#91;Haskell&#93; C++ bindings].
  +
:An e-mail describing how to link to C++
  +
  +
;[[HsLua]]
  +
:Haskell interface to Lua scripting language (tested with GHC 6.6/6.8).
  +
  +
;[http://hackage.haskell.org/package/hR hR]
  +
:Haskell interface to R
  +
  +
;[[Salsa]]
  +
:An experimental .NET Bridge for Haskell.
  +
  +
;[[/Erlang|Erlang]]
  +
:Impersonates an Erlang node on the network.
  +
  +
=== Obsolete ===
  +
  +
;[http://web.archive.org/web/20060411002808/http://www.reid-consulting-uk.ltd.uk/docs/ffi.html Guide to Haskell's Foreign Function Interface]
  +
:Comparision of the different tools.
  +
  +
;[http://web.archive.org/web/20100905111116/http://www.haskell.org/greencard/ Green Card]
  +
: Green Card is a foreign function interface preprocessor for Haskell, simplifying the task of interfacing Haskell programs to external libraries (which are normally exposed via C interfaces). Green Card is currently able to generate code compatible with [[Implementations#The_Haskell_Interpreter_Hugs| Hugs]] and [[Implementations#nhc98 | nhc]]. Green Card is compatible with the [[Implementations#GHC_the_Glasgow_Haskell_Compiler | Glasgow Haskell Compiler]] (GHC), versions prior to 6.2.
  +
:Green Card is not compatible with GHC versions 6.2 and later because Green Card uses a deprecated form of Foreign Function Interface (FFI) binding, _casm_: such old-style bindings were removed in GHC version 6.2. See [http://www.mail-archive.com/haskell@haskell.org/msg14004.html ANNOUNCE: GHC version 6.2].
  +
  +
;[http://web.archive.org/web/20100524024455/http://www.haskell.org/hdirect/ HaskellDirect]
  +
:HaskellDirect is an Interface Definition Language (IDL) compiler for Haskell, which helps interfacing Haskell code to libraries or components written in other languages (C). An IDL specification specifies the type signatures and types expected by a set of external functions. One important use of this language neutral specification of interfaces is to specify COM (Microsoft's Component Object Model) interfaces, and HaskellDirect offers special support for both using COM objects from Haskell and creating Haskell COM objects. HaskellDirect groks both the OSF DCE dialect of IDL (including the various extensions introduced by the Microsoft IDL compiler) and the OMG IIOP/CORBA dialect. '''Not compatible with recent versions of GHC (6.6.1)'''
  +
  +
  +
==== Java ====
  +
  +
;[http://labs.businessobjects.com/cal/ CAL]
  +
:A hybrid language of Java and Haskell.
  +
  +
;[http://www.haskell.org/gcjni GCJNI]
  +
:A Java Native Interface for Haskell. Allows Haskell to invoke Java code. Includes a tool to generate Haskell bindings for a Java library. Works for hugs and ghc under both Linux and Windows. (Based on Greencard, see above.)
  +
  +
;[http://sourceforge.net/projects/jvm-bridge/ Haskell/Java VM Bridge]
  +
:A bridge to the Java virtual machine via JNI for Haskell.
  +
  +
;[http://research.microsoft.com/en-us/um/people/emeijer/papers/lambada.pdf Lambada] (PDF)
  +
:A Haskell <=> Java interoperation bridge. Interoperation between Haskell and Java is provided by Lambada via the Java Native Interface (JNI), giving you a set of Haskell abstractions that lets you both call out to Java from Haskell *and* wrap up Haskell code behind a Java-callable veneer. '''Not compatible with recent versions of GHC (6.6.1)'''
  +
  +
;[http://wiki.brianweb.net/LambdaVM/ LambdaVM]
  +
:A set of patches and additions to GHC that let GHC compile from Core to JVM bytecode. Also has a FFI for calling native Java libraries.
  +
  +
  +
[[Category:FFI]]

Revision as of 23:49, 13 September 2013

The copyright status of this work is not known. Please help resolve this on the talk page.

This page contains a list of libraries and tools in a certain category. For a comprehensive list of such pages, see Libraries and tools.

Contents

1 Tools for interfacing with other languages

Haskell builtin features for interfacing to other languages are formally defined in the Foreign Function Interface (FFI). You may learn it by example at the IO inside guide.

See also Web services and RPC.

The following tools and libraries either simplify interfacing to C or allow interfacing to other languages and environments (COM, JVM, Python, Tcl, Lua...).

1.1 C

C->Haskell
A lightweight tool for implementing access to C libraries from Haskell.
c2hsc
A tool to create Bindings-DSL based interface files for C libraries.
HSFFIG
Haskell FFI Binding Modules Generator (HSFFIG) is a tool that takes a C library include file (.h) and generates Haskell Foreign Functions Interface import declarations for items (functions, structures, etc.) the header defines.
KDirect
A tool to simplify the process of interfacing C libraries to Haskell. It is less powerful than HaskellDirect, but easier to use and more portable.
libffi
A binding to libffi, allowing C functions of types only known at runtime to be called from Haskell.

1.2 Java

See the discussion on Haskell Cafe.

1.3 Python

MissingPy
MissingPy is really two libraries in one. At its lowest level, MissingPy is a library designed to make it easy to call into Python from Haskell. It provides full support for interpreting arbitrary Python code, interfacing with a good part of the Python/C API, and handling Python objects. It also provides tools for converting between Python objects and their Haskell equivalents. Memory management is handled for you, and Python exceptions get mapped to Haskell Dynamic exceptions. At a higher level, MissingPy contains Haskell interfaces to some Python modules.

1.4 Others

fficxx
A Haskell-C++ Foreign Function Interface Generator
Smarty
An interface between Haskell and Squeak, a freely available Smalltalk language and environment.
[1]
lp2fp is a program-translator from Prolog to Haskell.
HaskellScript
HaskellScript is the collective name for all Haskell components, both tools and libararies, that allow interaction with the COM/ActiveX framework.
TclHaskell
TclHaskell is a haskell binding to Tcl-Tk that lets you build GUIs in Haskell. It is Haskell98 compliant. It has been tested under hugs98 and ghc-4.04.
CPlusPlusFromHaskell
A hackish method calling C++ from Haskell.
Re: [Haskell] C++ bindings.
An e-mail describing how to link to C++
HsLua
Haskell interface to Lua scripting language (tested with GHC 6.6/6.8).
hR
Haskell interface to R
Salsa
An experimental .NET Bridge for Haskell.
Erlang
Impersonates an Erlang node on the network.

1.5 Obsolete

Guide to Haskell's Foreign Function Interface
Comparision of the different tools.
Green Card
Green Card is a foreign function interface preprocessor for Haskell, simplifying the task of interfacing Haskell programs to external libraries (which are normally exposed via C interfaces). Green Card is currently able to generate code compatible with Hugs and nhc. Green Card is compatible with the Glasgow Haskell Compiler (GHC), versions prior to 6.2.
Green Card is not compatible with GHC versions 6.2 and later because Green Card uses a deprecated form of Foreign Function Interface (FFI) binding, _casm_: such old-style bindings were removed in GHC version 6.2. See ANNOUNCE: GHC version 6.2.
HaskellDirect
HaskellDirect is an Interface Definition Language (IDL) compiler for Haskell, which helps interfacing Haskell code to libraries or components written in other languages (C). An IDL specification specifies the type signatures and types expected by a set of external functions. One important use of this language neutral specification of interfaces is to specify COM (Microsoft's Component Object Model) interfaces, and HaskellDirect offers special support for both using COM objects from Haskell and creating Haskell COM objects. HaskellDirect groks both the OSF DCE dialect of IDL (including the various extensions introduced by the Microsoft IDL compiler) and the OMG IIOP/CORBA dialect. Not compatible with recent versions of GHC (6.6.1)


1.5.1 Java

CAL
A hybrid language of Java and Haskell.
GCJNI
A Java Native Interface for Haskell. Allows Haskell to invoke Java code. Includes a tool to generate Haskell bindings for a Java library. Works for hugs and ghc under both Linux and Windows. (Based on Greencard, see above.)
Haskell/Java VM Bridge
A bridge to the Java virtual machine via JNI for Haskell.
Lambada (PDF)
A Haskell <=> Java interoperation bridge. Interoperation between Haskell and Java is provided by Lambada via the Java Native Interface (JNI), giving you a set of Haskell abstractions that lets you both call out to Java from Haskell *and* wrap up Haskell code behind a Java-callable veneer. Not compatible with recent versions of GHC (6.6.1)
LambdaVM
A set of patches and additions to GHC that let GHC compile from Core to JVM bytecode. Also has a FFI for calling native Java libraries.