Template Haskell and the command line

Simon Peyton-Jones simonpj at microsoft.com
Thu Dec 18 10:28:59 EST 2003

Simon M has persuaded me that -D/-U are really cpp-specific flags.
What's to stop you using the environment variables directly?

Suppose you had

	getEnvVar :: String -> Q (Maybe String)

which is pretty much what System.getEnv does.  Would that do the job?
Then you could say

	DEBUG=yes ghc -fth Foo.hs


| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org
| bounces at haskell.org] On Behalf Of George Russell
| Sent: 02 December 2003 15:32
| To: glasgow-haskell-users at haskell.org
| Subject: Template Haskell and the command line
| 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
| functions which look at them.
| Of course one /could/ presumably use System.getArgs and analyse the
| 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
| another way.  Thanks for Template Haskell!
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

More information about the Glasgow-haskell-users mailing list