[Haskell-cafe] preprocessor, how to?
Kees Bleijenberg
k.bleijenberg at lijbrandt.nl
Mon Jan 6 08:13:25 UTC 2014
In a program I use a lot of hamlet files. All these hamlet files are in a
submap of the source map. In code:
allHtml = Mconcat [ $(hamletFile "hamlet\\belastingen.hamlet") renderUrl
,$(hamletFile "hamlet\\winddruk.hamlet") renderUrl
..
,$(hamletFile "hamlet\\berekeningDruk.hamlet")
renderUrl
,$(hamletFile "hamlet\\drukNaarBuigTrek.hamlet")
renderUrl]
This is a Windows program.
For another project I want to use this piece of code on Linux. The code
should now be:
.. $(hamletFile "hamlet/winddruk.hamlet") renderUrl
I can't use pathSeparator here, because this is all happening at compile
time. So I think I need a preprocessor.
I would like to have a kind of hamletDir macro and change the code to
something like:
#ifdef Win32
hamletDir = "hamlet\\"
#else
hamletDir = "hamlet/"
#endif
...
$(hamletFile "{hamletDir}winddruk.hamlet") renderUrl
Is it possible in Haskell and how do I it?
All examples of preprocessing in Haskell I found are something like this:
#ifdef xxx
aaaa
#else
Bbbbb
#endif
I could use that. But a user defined macro is less code.
Kees
More information about the Haskell-Cafe
mailing list