A long-standing gap in Haskell environments is the lack of tools
(written in Haskell, of course :-) for the manipulation or analysis of
Haskell source programs. Other languages have a rather rich collection
of such tools:
* C sources can be formatted automatically by indent, transformed
from ANSI to K&R-style with ansi2knr, prototypes can be generated
automatically by mkproto, etc.
* HTML documentation can be generated from Java sources with
javadoc.
* Program slicing tools are available for a range of languages.
* Pretty-Printers
* ...
One of the biggest obstacles for building similar tools for Haskell is
the daunting task of writing a parser (a recurring theme in this
mailing list). Although there are parsing libraries and a
lexer/parser-generator available, it is nonetheless a difficult and
time-consuming thing to do for several reasons:
* The grammar for full Haskell is quite large (note that some
productions in the report are indexed by precedence and
associativity).
* The grammar in the report is highly ambiguous, therefore making
it unsuitable for the input of parser generators.
* Handling fixity declarations and the layout rule further
complicates matters.
Why not simply reuse parts of existing Haskell systems for this task?
They are not very well suited for inclusion in other projects because
of several reasons:
* Hugs is a C-only system, GHC and HBC use an awesome mixture of C
and Haskell. This makes them hard to use if the rest of the tool
is written in Haskell. Furthermore, the tool couldn't be labeled
"100% pure Haskell" anymore... :-)
* The yacc/bison specs in GHC/HBC contain *lots* of conflicts
(HBC's curry.y produces more than 80 conflicts). This certainly
lowers the confidence that the generated parser does the right
thing, even more if one wants to incorporate small changes. One
has to check for every conflict if the default action taken is
the right one. Not much fun...
* There are often strong interdependencies between the parser and
the rest of the compiler (used libraries etc.).
* It's hard to figure out the generated abstract syntax and the
mapping between it and the corresponding Haskell constructs.
So what do we need for the easy construction of useful tools for
Haskell? First of all a well-documented and easily comprehensible
abstract syntax in the form of algebraic datatype declarations and a
Haskell-only parser are needed. The emphasis should be on
maintainability, completeness and ease of inclusion in other programs,
not speed. Furthermore, a pretty-printer (aka unparser) would be
useful, too.
So here is my call for contribution:
Send an abstract syntax and/or a parser specification!
It doesn't matter if a parser generator is used or recursive descent
techniques are applied.
If there is enough echo, I'd like to setup a web page for this
project, containing things to download, documentation, and giving a
forum for discussions and applications of the parsers. Ideas range
from simple formatting tools to library browsers ("I know there is a
function with a similar type signature somewhere...") or computer
aided source-to-source transformations.
Don't hesitate, contribute!
--
Sven Panne Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen Oettingenstr. 67
mailto:[EMAIL PROTECTED] D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne