DrIFT...
...once known as Derive |
|
I've not got the time to actively maintain DrIFT at the moment. Happily,
Malcolm Wallace has produced
an updated implementation for Haskell 98. He writes
Other changes include the addition of a rule for deriving the "Binary"
class (available as a library for both nhc98 and ghc), and altering
Main.main to write its results to stdout instead of overwriting the
original file.
So far, I have only tested this version of DrIFT with nhc98 - I do not
have the latest version of ghc available. Hence, it will probably
require a little bit of tweaking to be made completely portable.
The sources are here:
ftp://ftp.cs.york.ac.uk/pub/haskell/contrib/DrIFT-1.0-98.tar.gz
Introduction
DrIFT is a type sensitive preprocessor for
Haskell. It extracts type declarations
and directives from modules. The directives cause rules to be fired on
the parsed type declarations, generating new code which is then appended
to the bottom of the input file. The rules are expressed as Haskell code,
and it is intended that the user can add new rules as required.
DrIFT is written in Haskell 1.4, can be
compliled using GHC
2.2 or higher, or interpreted using Hugs
1.4
So, what does DrIFTdo?
DrIFT automates instance derivation for classes
that aren't supported by the standard compilers. In addition, instances
can be produced in seperate modules to that containing the type declaration.
This allows instances to be derived for a type after the original module
has been compiled. As a bonus, simple utility functions can also be produced
from a type.
Features
-
DrIFT comes with a set of rules to produce
instances for all derivable classes given in the Hasekell Prelude. There's
a rule to produce instances of NFData
(the orignal motivation of all this), and rules for utility functions on
types also.
-
DrIFT performs import chasing to find the
definition of a type.
-
In addition to literate and non-literate scripts,
DrIFT is able to extract information from interface files generated by
the GHC compiler
-
Code is generated using pretty-printing
combinators. This means that the output is (fairly) well formatted,
and easy on the eye.
-
Effort has been made to make the rule interface
as easy to use as possible. This is to allow users to add rules to generate
code specific to their own projects. As the rules are themselves written
in Haskell, the user doesn't have to learn a new language to express rules.
DrIFT Distribution
I'd like to hear comments, criticism, or praise?
from anybody using DrIFT . I'd be especially interested in any new rules
written for it. Feel free to suggest improvements or bug fixes too.
Progress
For some time I've been meaning to go back
to the source code, rewriting & debugging sections of it. I've
still not gotten round to doing this, but plan to do so before Christmas
1998. Improvements planned include :
-
Support for multi-parameter type classes &
other features of the new type checker
-
Bugfixes.The current distribution has a few
problems:
-
somtimes it chokes on literate scripts
-
Import chasing fails occasionally
-
know of any more? get in touch
-
Possibly change the command syntax -- use
standard `deriving clauses', use as a pre-processor for Hugs
-
Add a better installation mechanism
nww@dcs.gla.ac.uk