[Haskell-cafe] Functional MetaPost in 5 Steps

Jared Updike jupdike at gmail.com
Fri Oct 24 01:13:10 EDT 2008

I'm interested in using Functional MetaPost on Mac OS X (or FreeBSD).
I'm looking for a tutorial like:


but for FMP. I can't even get a simple example to show up in a PDF file:
import FMP
... (see full code below)
myPicture = text "Hello World"
main = do
   print $ emit $ metaPost 1 myPicture params
When run, this emits MetaPost, which, after running through my shell
script, below, won't show up in my PDF... (this same TeX file will
show an .eps figure I made with PyX, the Python equivalent of FMP,
when I change includegraphics to use that file instead of test.1)

What am I missing? If I can get this working I will gladly write the
FMP 5 Step Tutorial. I like the idea of using FMP but I can't for the
life of me understand why running a toy example is so non-trivial.
(Not to mention undocumented... the manual and tutorials are very
compelling but they don't mention how to get a viewable PDF out of any
of the otherwise enticing examples.)


Relevant almost working code:


import FMP

params = Parameters {
  prolog = "verbatimtex\n\
             \input boxes\n\
             \input FuncMP\n\n",
  epilog= "\n\n\\end",

  defaultDX= 3,
  defaultDY= 3,
  textDX= 2,
  textDY= 2,

  newmp= True,

  funcmpRTS= "IGNORE", --"+RTS -H40m -K3M -RTS",
  funcmpBin= "IGNORE", -- "~/FuncMP-1.2/FuncMP",

   mpBin= "IGNORE" -- "MPINPUTS=:~/FuncMP-1.2 TEX=latex mpost "

myPicture = text "blah"

main = do
   print $ emit $ metaPost 1 myPicture params









shell script:

ghc --make Test.hs && \
  ./Test > test.mp && \
  mpost test.mp && \
  latex test.tex && \
  latex test.tex && \
  dvipdfm test.dvi && \
  open test.pdf   # MacOS X runs my pdf in preview

More information about the Haskell-Cafe mailing list