diff --git a/Makefile b/Makefile
new file mode 100644
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,30 @@
+.PHONY:	ghci pubs hackbib
+
+# problem: bibtex refuses to generate empty bbl files
+# thus you must have at least one entry per publication type
+TYPES := conference journal popular program \
+	reviewedconference reviewedjournal techreport thesis
+
+ghci:
+	ghci -Wall -i:src src/Publications.hs
+
+pubs:	tex/publications.pdf
+
+%.pdf:	%.tex %-cite.tex $(patsubst %, tex/%.bbl, $(TYPES))
+	(cd $(dir $<); pdflatex $(notdir $<); pdflatex $(notdir $<))
+
+%-cite.tex:	%.bib
+	ghc -e main src/Publications.hs < $< >$@
+
+%.bbl:	%.aux tex/publications.bib
+	(cd $(dir $<); bibtex $(notdir $*))
+
+tex/%.aux: tex/publications.tex
+	(cd $(dir $<); pdflatex $(notdir $<))
+
+
+hackbib:	hackage.bib
+
+hackage.bib:	$(HOME)/.cabal/packages/hackage.haskell.org/00-index.tar.gz
+	gunzip --stdout $< | ghc -e main src/Hackage.hs >$@
+#	gunzip --stdout $< | hackage-bibtex >$@
diff --git a/bibtex.cabal b/bibtex.cabal
--- a/bibtex.cabal
+++ b/bibtex.cabal
@@ -1,5 +1,5 @@
 Name:             bibtex
-Version:          0.0.1
+Version:          0.0.3
 License:          BSD3
 License-File:     LICENSE
 Author:           Henning Thielemann <haskell@henning-thielemann.de>
@@ -11,9 +11,46 @@
   This package allows parsing, formatting and processing of BibTeX files.
   BibTeX files are databases for literature for the natbib package
   of the LaTeX typesetting system.
+  .
+  The package contains two examples:
+  .
+  * The first example demonstrates the BibTeX parser
+    by generating a publication overview from a @.bib@ file.
+  .
+  * The second example demonstrates the BibTeX generation
+    by producing a large @.bib@ file from the tar archive
+    that cabal-install downloads to your local cabal directory.
+  .
+  Both examples will be build as stand-alone executable
+  when running
+  .
+  > cabal install -fbuildExamples bibtex
+  .
+  For the first example see the "tex" directory of this package.
+  You can start the program and build an example document by running
+  .
+  > make pubs
+  .
+  Technically the program generates a list of custom @\\nocite@ commands
+  for the LaTeX package @multibib@.
+  You can add the custom bibtex field @subtype@ to BibTeX entries
+  for more detailed categorization of an entry.
+  See "tex/publications.bib" for examples.
+  .
+  The second example can be executed using
+  .
+  > make hackbib
+  .
+  The file @hackage.bib@ is written to the current directory.
+  The program reads an uncompressed tar archive from standard input
+  and writes the result bibliography file to standard output.
 Tested-With:      GHC==6.10.4
 Cabal-Version:    >=1.6
 Build-Type:       Simple
+Extra-Source-Files:
+  Makefile
+  tex/publications.tex
+  tex/publications.bib
 Source-Repository head
   type:     darcs
   location: http://code.haskell.org/~thielema/bibtex/
@@ -21,7 +58,7 @@
 Source-Repository this
   type:     darcs
   location: http://code.haskell.org/~thielema/bibtex/
-  tag:      0.0.1
+  tag:      0.0.3
 
 Flag base2
   description: Choose the new smaller, split-up base package.
@@ -32,7 +69,7 @@
 
 Library
   Build-Depends:
-    parsec >=2.1 && <2.2,
+    parsec >=2.1 && <3.1,
     utility-ht >=0.0.5 && <0.1
   If flag(base2)
     Build-Depends:
@@ -58,3 +95,17 @@
   GHC-Options:      -Wall
   Hs-source-dirs:   src
   Main-Is:          Publications.hs
+
+Executable       hackage-bibtex
+  If flag(buildExamples)
+    Build-Depends:
+      old-time >=1.0 && <1.1,
+      Cabal >=1.6 && <1.10,
+      tar >=0.3 && <0.4,
+      bytestring >=0.9 && <0.10
+  Else
+    Buildable:      False
+
+  GHC-Options:      -Wall
+  Hs-source-dirs:   src
+  Main-Is:          Hackage.hs
diff --git a/src/Hackage.hs b/src/Hackage.hs
new file mode 100644
--- /dev/null
+++ b/src/Hackage.hs
@@ -0,0 +1,102 @@
+module Main where
+
+import qualified Distribution.PackageDescription.Parse as PkgP
+import qualified Distribution.PackageDescription as PkgD
+import qualified Distribution.Package as Pkg
+import qualified Distribution.Verbosity as Verbosity
+import Distribution.PackageDescription
+                   (PackageDescription, )
+import Distribution.Package
+                   (PackageIdentifier(..), )
+import Distribution.PackageDescription.Parse
+                   (parsePackageDescription,
+                    readPackageDescription, )
+import System.Time (ClockTime(TOD), getClockTime,
+                    toCalendarTime, toUTCTime,
+                    CalendarTime, ctYear, ctMonth, )
+
+import qualified Codec.Archive.Tar as Tar
+import qualified Codec.Archive.Tar.Entry as TarEnt
+import qualified Data.ByteString.Lazy as B
+import qualified System.IO as IO
+
+import Distribution.Text (display, )
+
+import Data.List.HT (dropWhileRev, )
+import Data.Char    (toLower, isSpace, isAlpha, chr, )
+import Data.Version (showVersion, )
+import qualified Data.List as List
+
+
+{- |
+See hackage-server:Distribution/Server/Pages/Package.hs
+-}
+packageURL :: PackageIdentifier -> String
+packageURL pkgid = "/package/" ++ display pkgid
+
+
+fromPackage :: CalendarTime -> PackageDescription -> String
+fromPackage time pkg =
+   let author =
+          let str = dropWhile isSpace $ PkgD.author pkg
+          in  case str of
+                 '"' : t -> takeWhile ('"' /=) t
+                 _ -> dropWhileRev isSpace $ takeWhile ('<' /=) str
+       surname =
+          let nameParts = words author
+          in  if null nameParts
+                then ""
+                else filter isAlpha $ last nameParts
+       pkgId = PkgD.package pkg
+       Pkg.PackageName name = Pkg.pkgName pkgId
+       year = ctYear time
+       versionStr = showVersion (Pkg.pkgVersion pkgId)
+   in  unlines $
+       ("@Misc{" ++ map toLower surname ++ show year ++
+                    name ++ "-" ++ versionStr ++ ",") :
+       map (\(field,value) -> "  " ++ field ++ " = {" ++ value ++ "},") (
+          ("author", author) :
+          ("title", "{" ++ name ++ ": " ++ PkgD.synopsis pkg ++ "}") :
+          ("howpublished",
+              "\\url{http://hackage.haskell.org" ++
+              packageURL (PkgD.package pkg) ++ "}") :
+          ("year", show year) :
+          ("month", show (ctMonth time)) :
+          ("version", versionStr) :
+          ("keywords", "Haskell, " ++ PkgD.category pkg ) :
+          ("subtype", "program") :
+          []) ++
+       "}" :
+       []
+
+example :: IO ()
+example =
+   do now <- toCalendarTime =<< getClockTime
+      pkg <- readPackageDescription Verbosity.silent "example.cabal"
+      putStrLn (fromPackage now (PkgD.packageDescription pkg))
+
+
+fromTarEntry :: Tar.Entry -> String
+fromTarEntry ent =
+   if List.isSuffixOf ".cabal" (TarEnt.entryPath ent)
+     then
+       case TarEnt.entryContent ent of
+          TarEnt.NormalFile txt _size ->
+             case parsePackageDescription
+                     (map (chr . fromIntegral) (B.unpack txt)) of
+                PkgP.ParseOk _ pkg ->
+                   fromPackage
+                      (toUTCTime (TOD (fromIntegral $ TarEnt.entryTime ent) 0))
+                      (PkgD.packageDescription pkg)
+                PkgP.ParseFailed msg -> show msg
+          _ -> ""
+     else ""
+
+main :: IO ()
+main =
+   Tar.foldEntries
+      (\entry cont ->
+         putStrLn (fromTarEntry entry) >> cont)
+      (return ()) (IO.hPutStr IO.stderr) .
+   Tar.read =<<
+   B.getContents
diff --git a/src/Text/BibTeX/Parse.hs b/src/Text/BibTeX/Parse.hs
--- a/src/Text/BibTeX/Parse.hs
+++ b/src/Text/BibTeX/Parse.hs
@@ -72,7 +72,7 @@
 bibIdentifier =
    liftM2 (:)
       Parsec.letter
-      (Parsec.many (Parsec.alphaNum <|> Parsec.oneOf "-_."))
+      (Parsec.many (Parsec.alphaNum <|> Parsec.oneOf ":-_."))
 
 {- |
 Extends a parser, such that all trailing spaces are skipped.
diff --git a/tex/publications.bib b/tex/publications.bib
new file mode 100644
--- /dev/null
+++ b/tex/publications.bib
@@ -0,0 +1,74 @@
+@InProceedings{alfer2002beginning,
+  author =	 {Alfer, Ralf and Thielemann, Henning},
+  title =	 {The beginning of everything},
+  booktitle =	 {42 articles about everything},
+  subtype =	 {reviewed},
+  year =	 2002,
+  month =	 {June},
+}
+
+@Article{thielemann2000foobar,
+  author =	 {Thielemann, Henning},
+  title =	 {Foo Bar},
+  journal =	 {Journal of Irrelevant Applications},
+  subtype =	 {popular},
+  month =	 {December},
+  year =	 2000,
+  pages =	 {123--321},
+  volume =	 88,
+  number =	 7,
+}
+
+@TechReport{thielemann2000prefoobar,
+  author =	 {Thielemann, Henning},
+  title =	 {Before Foo becomes Bar},
+  institution =	 {University of Applied Irrelevance},
+  year =	 2000
+}
+
+@Article{thielemann2001nonexistence,
+  author =	 {Curry, Haskell Brooks and Thielemann, Henning},
+  title =	 {Non-existence proof of certain articles},
+  journal =	 {Journal of Logical Consequences},
+  subtype =	 {reviewed},
+  year =	 2001,
+  volume =	 21,
+  number =	 4,
+  pages =	 {219--226},
+  month =	 {August},
+}
+
+@InProceedings{thielemann2002mass,
+  author =	 {Thielemann, Henning},
+  title =	 {Mess for the Masses},
+  booktitle =	 {Annual conference of the Society of Measurement},
+  year =	 2002,
+  month =	 {September},
+}
+
+@Article{thielemann2002other,
+  author =	 {Thielemann, Henning and others},
+  title =	 {Make things different},
+  journal =	 {The Other Journal},
+  year =	 2002,
+  volume =	 42,
+  number =	 7,
+  pages =	 {271--314},
+  month =	 {January},
+}
+
+@PhdThesis{thielemann2006diss,
+  author =	 {Thielemann, Henning},
+  title =	 {Equivalence of Foo and Bar},
+  school =	 {University of Applied Irrelevance},
+  year =	 2006,
+  month =	 {March}
+}
+
+@Misc{thielemann2010bibtex,
+  key =		 {haskell, bibtex, natbib},
+  author =	 {Thielemann, Henning},
+  title =	 {BibTeX parsing and generation},
+  howpublished = {\url{http://hackage.haskell.org/package/bibtex}},
+  subtype =	 {program},
+}
diff --git a/tex/publications.tex b/tex/publications.tex
new file mode 100644
--- /dev/null
+++ b/tex/publications.tex
@@ -0,0 +1,65 @@
+\documentclass[a4paper]{article}
+
+\usepackage{times}
+
+\usepackage{color}
+\definecolor{dark-green}{rgb}{0.0,0.5,0.0}
+
+\usepackage[colorlinks,citecolor=dark-green]{hyperref}
+
+
+\renewcommand{\familydefault}{\sfdefault}
+
+
+\usepackage{multibib}
+
+\newcites{reviewedjournal}{Reviewed Journals}
+\newcites{reviewedconference}{Reviewed Conferences}
+\newcites{techreport}{Technical Reports}
+\newcites{journal}{Other Journals}
+\newcites{conference}{Other Conferences}
+\newcites{thesis}{Theses}
+\newcites{program}{Programming Projects}
+\newcites{popular}{Popular Scientific Articles}
+
+
+\sloppy
+
+
+\begin{document}
+
+\input{publications-cite}
+
+\bibliographystylereviewedjournal{plain}
+\bibliographyreviewedjournal{publications}
+
+
+\bibliographystylereviewedconference{plain}
+\bibliographyreviewedconference{publications}
+
+
+\bibliographystyletechreport{plain}
+\bibliographytechreport{publications}
+
+
+\bibliographystylejournal{plain}
+\bibliographyjournal{publications}
+
+
+\bibliographystyleconference{plain}
+\bibliographyconference{publications}
+
+
+\bibliographystylethesis{plain}
+\bibliographythesis{publications}
+
+
+\bibliographystyleprogram{plain}
+\bibliographyprogram{publications}
+
+
+\bibliographystylepopular{plain}
+\bibliographypopular{publications}
+
+
+\end{document}
