Template Haskell and the command line
Simon Marlow
simonmar at microsoft.com
Mon Dec 8 12:33:25 EST 2003
> Template Haskell is frightfully good and we want to get rid of cpp and
> use it instead, but there's one tiny problem, namely that for cpp it
> is possible to define variables on the command line
> (-DSIMON=MARLOW and so
> on) while with Template Haskell it doesn't seem to be. Could there be
> some kind of dictionary, like the cpp environment variables, which the
> Template Haskell code has access to?
>
> One obvious way would be to accept the -D/-U arguments, and
> provide Haskell
> functions which look at them.
>
> Of course one /could/ presumably use System.getArgs and
> analyse the arguments
> to ghc oneself, but that would mean making guesses about the
> current GHC syntax.
>
> In the meantime we shall still replace cpp with Template
> Haskell, but find
> another way. Thanks for Template Haskell!
What's wrong with using environment variables, with
System.Envorinment.getEnv? To use your example, you would write:
$ SIMON=MARLOW foo
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list