[Haskell-cafe] preprocessor, how to?
Erik Hesselink
hesselink at gmail.com
Mon Jan 6 20:16:13 UTC 2014
I don't quite understand why you can't just use pathSeparator (or </>)
here. The code in the quotes is still Haskell, and it's going to
compile on the same platform it's going to run on, right?
Erik
On Mon, Jan 6, 2014 at 9:13 AM, Kees Bleijenberg
<k.bleijenberg at lijbrandt.nl> wrote:
> 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
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list