diff --git a/Main.hs b/Main.hs
new file mode 100644
--- /dev/null
+++ b/Main.hs
@@ -0,0 +1,18 @@
+module Main where
+
+import Control.Applicative ((<$>))
+import Control.Arrow ((>>>),(<<<))
+import Language.Prolog (consult, parseQuery)
+import ParseArgs (parseArgs)
+import GraphViz (resolveTree, resolveTreeToFile)
+
+main = do
+   (queryString, files, output) <- parseArgs
+   p <- concat <$> mapM ((abortOnError=<<) . consult) files
+   q <- abortOnError $ parseQuery queryString
+   resolveTreeToFile output p q
+   --case output of
+   --   Nothing -> resolveTree p q {- FIXME Never shown since thread terminated. -}
+   --   Just file -> resolveTreeToFile file p q >> return ()
+
+abortOnError = either (error . show) return
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/prolog-graph.cabal b/prolog-graph.cabal
new file mode 100644
--- /dev/null
+++ b/prolog-graph.cabal
@@ -0,0 +1,30 @@
+Name:                prolog-graph
+Version:             0.1
+Synopsis:            A command line tool to visualize query resolution in Prolog.
+Description:         This package installs the command line tool `hsprolog-graph` that
+                     generates images of resolution trees for given Prolog queries.
+                     .
+                     See @hsprolog-graph --help@ for more information on usage.
+License:             PublicDomain
+Author:              Matthias Bartsch
+Maintainer:          bartsch@cs.uni-bonn.de
+Homepage:            https://github.com/Erdwolf/prolog
+Category:            Language
+Build-type:          Simple
+Cabal-version:       >=1.6
+
+Source-repository head
+   type: git
+   location: git://github.com/Erdwolf/prolog.git
+
+Executable hsprolog-graph
+  Main-is: Main.hs
+
+  Build-depends:
+    prolog == 0.1.*,
+    base >=4 && <5,
+    fgl >= 5.4.2.4,
+    mtl >= 2.0.1.0,
+    cmdargs >= 0.8,
+    text >= 0.11.1.5,
+    graphviz
