Sunday, March 8, 2009

Pandoc. Can we use it ouside of Haskell?

Pandoc is great. It a Markdown implementation on steroids, supporting a number of different input/output formats besides HTML, such as TeX. And yet it is Markdown: the source still looks great, just like plain email! As an extra bonus, Pandoc, being written in Haskell and compiled to native code, works a lot faster than many alternative markup language processors.

The problem is.. It is a Haskell library. If it is indeed the great software it seems to be, one would want to use it from scripting languages (PHP, Python, Perl), OCaml, Schemes, Java, .NET and so on.

The first step towards that is to bind it to C.

Good news: yes, it is possible, and Pandoc DLL or Shared Object builds on both Windows and Linux. It is callable from other languages (currently C and PLT Scheme).

Bad news: the binary is large, as GHC compiles everything, including its runtime, into it. The binding is untested, poorly configured and very incomplete. But, well, it is open-source and will get better with time. You can see for yourself: libpandoc


  1. Hi,

    Great idea ... but I'm having a problem compiling the lib:
    ghc -O2 -optl-s --make -no-hs-main -optl-shared -o libpandoc.hs libpandoc-so.c

    Could not find module `Text.JSON':
    Use -v to see a list of the files searched for.
    make: *** [] Erreur 1

    maybe it's a simple problem (like a haskell lib missing) but I don't know anything about haskell so maybe you can give me a few hints ... my plaform is ubuntu 8.10 ...

  2. I had the same problem - You need to install cabal, which is the package manager for Haskell. See here: