replacing the Prelude (again)
Olaf Chitil
olaf@cs.york.ac.uk
Mon, 15 Jul 2002 16:04:43 +0100
Malcolm Wallace wrote:
> > For what reasons do you require the original prelude?
>
> Exactly the same reasons. We want to do as little desugaring as
> necessary in the transformation, so inevitably we need at least a
> small part of the Prelude in scope.
This is a bit misleading. We do desugar as far as possible anything that
refers to prelude functions, e.g. list comprehensions and do notation
(these constructs could still be traced specially, although currently
this is not the case). However, the transformed program does contain
numeric literals and according to the Haskell 98 definition a compiler
will add an implicit fromInteger etc to every such literal. According to
Haskell 98 this fromInteger always refers to the Prelude. We want to
produce Haskell 98 code and hence do not want to rely on any
non-standard -no-implicit-prelude option, but we may use it circumvent
the current problem of lack of defaulting.
(Our transformation does add its own TPrelude.fromInteger to every
literal, but that is a separate issue).
At the moment I cannot think of any other original Prelude function in a
transformed program.
Naturally the transformed Prelude and also our tracing combinators use
the original Prelude heavily.
Btw Bernie, I'm surprised you say that transforming the Prelude was no
problem for you. It did take me quite a lot of time. The problem is that
altough most of it is just Haskell, some parts are primitive. So the
Prelude has to be split into a transformable part and a core part, the
tracing version of which needs to be written by hand. Also the Prelude
and some standard library modules are mutually recursive, which no
Haskell compiler handles easily. Hence I defined one large module, from
which both Prelude and some standard libraries import, but only export
parts of it. It is also tricky to avoid recursive dependencies between
core and transformable parts.
Ciao,
Olaf
--
OLAF CHITIL,
Dept. of Computer Science, The University of York, York YO10 5DD, UK.
URL: http://www.cs.york.ac.uk/~olaf/
Tel: +44 1904 434756; Fax: +44 1904 432767