The language-c-inline package

[Tags:bsd3, library]

This library provides inline C & Objective-C code using GHC's support for quasi-quotation. In particular, it enables the use of foreign libraries without a dedicated bridge or binding. Here is a tiny example:

 nslog :: String -> IO ()
 nslog msg = $(objc ['msg :> ''String] (void [cexp| NSLog(@"Here is a message from Haskell: %@", msg) |]))

For more information, see

Known bugs:

[Skip to Readme]


Versions,,,,,,,,,,, (info)
Dependencies array, base (>=4.0 && <5), containers (>=0.4), filepath (>=1.2), language-c-quote (==0.8.*), mainland-pretty (>=0.2.5), template-haskell [details]
License BSD3
Author Manuel M T Chakravarty
Maintainer Manuel M T Chakravarty <>
Category Language, Foreign
Home page
Bug tracker
Source repository head: git clone git://
Uploaded Tue Nov 1 03:19:23 UTC 2016 by ManuelChakravarty
Distributions NixOS:
Downloads 1973 total (5 in the last 30 days)
0 []
Status Docs not available [build log]
All reported builds failed as of 2016-11-18 [all 3 reports]
Hackage Matrix CI


  • Language
    • C
      • Inline
        • Language.C.Inline.ObjC


manualtestsEnables tests that require manual intervention.DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for language-c-inline

Readme for language-c-inline-

Inline C & Objective-C in Haskell

This library uses Template Haskell and language-c-quote, a quasi-quotation library for C-like languages, to provide inline C and Objective-C in Haskell. It extracts the C/Objective-C code automatically, when compiling the Haskell program, and generates marshalling code for common types. The wiki on GitHub details the motivation for this approach.

For further motivation, have a look at the slides of my YOW! Lambda Jam 2014 talk Foreign Inline Code in Haskell.


To build the library, just use cabal install as usual from the source code directory or by installing from Hackage.

You may like to have a look at a minimal example of its use, which you can build as follows:

  • Execute cd tests/objc/minimal; make.
  • Now run the demo executable with ./Minimal.

To build the proof of concept example, do the following:

  • Execute cd tests/objc/concept; make.
  • Now run the demo executable with ./InlineObjC.

To build an example class wrapping a Haskell record, do the following:

  • Execute cd tests/objc/record; make.
  • Now run the demo executable with ./Particle.

To build the more complex Haskell interpreter app:

  • Execute cd tests/objc/app; make.
  • Now open -a

I tested it with Haskell Platform 2013.2.0.0 (which includes GHC 7.6.3) and it requires the latest version of language-c-quote, which is currently 0.7.7.


The library is in beta and so far focuses on Objective-C. Automatic marshalling support is still somewhat limited. However, it is quite easy to add more types, and I do welcome pull request!