[Haskell-cafe] File path programme

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Jan 27 13:15:05 EST 2005


John Meacham <john at repetae.net> writes:

> too bad we can't do things like
>
> #if exists(module System.Path) 
> import System.Path
> #else
> ...
> #endif
>
> I still find it perplexing that there isn't a decent standard haskell
> preprocessor.... 

For my language Kogut I designed a syntax

   ifDefined condition {
      something
   }
   otherCondition {
      something else
   }
   ...

where a condition is an identifier whose definedness is tested, or
"module ModuleName" for existence of a module, or _ which is always
true, or their combination using conjunctions, alternatives and
negations.

The construct can be an expression (no condition is true => Null,
which makes sense with dynamic typing), a definition (no condition
is true => nothing is defined) or a pattern (no condition is true =>
a pattern which never matches).

It does not subsume Common Lisp's #+ and #- nor vice versa. In Lisp
it is done at read time, not compile time, which has some advantages,
but is incompatible with temporal separation of compilation phases.

Even though definitions may in general be mutually recursive,
similarly as in Haskell, ifDefined depends only on definitions above
it. This is hard to avoid, because its expansion may influence the set
of definitions which will be present.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


More information about the Haskell-Cafe mailing list