A Haskell specific preprocessor

Eray Ozkural (exa) erayo@cs.bilkent.edu.tr
Fri, 11 Jan 2002 18:12:03 +0200


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 11 January 2002 15:04, Keith Wansbrough wrote:
> but most people seemed to believe that a lazy language shouldn't need
> macros or a preprocessor (despite the liberal use of both in GHC, for
> example).

I'm hoping I will not have to use any sort of macro preprocessor that has 
survived from 1965.

If you need it for platform compatibility switches I would reckon that you 
can do it at the file level [+]. It looks much nicer, see tcl/tk sources. I 
can tell from experience that writing a C++ class with #ifdef 's in the 
middle of the interface is the worst possible kind of coding. [*]

I don't see any other reason why someone would want to use a macro 
preprocessor except accidental habits. Any sort of configuration which does 
not prevent compilation (i.e. availability of a library), can be implemented 
in run time. That is probably better/more extensible design as well.

Everything else a macro procesor is used for in low/medium level languages 
like C can be elegantly defined in a higher level language such as Haskell.

Thanks,

[+] Though I have no idea how you could do that with a Haskell build system, 
is there something like a VPATH that haskell compiler recognizes? There might 
be some problems implementing different files for different platforms 
approach without such a feature. Maybe you could simply symlink the required 
files into a source dir in a build system and compile there. Might not be 
very portable to a certain less-than-UNIX system though. :) 
[*] I try not to use any CPP except #include's in C++.

- -- 
Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8Pw7VfAeuFodNU5wRAkSgAJ4lwi+tqeRauZZZpRJXkRl3wPH2pQCdGip7
aGmebPcRSXVTzzedZCXgH6A=
=sUuT
-----END PGP SIGNATURE-----