[Haskell-cafe] preprocessor, how to?

Chris Wong chrisyco+haskell-cafe at gmail.com
Mon Jan 6 08:25:25 UTC 2014


You can use forward slashes in Windows as well.
On Jan 6, 2014 9:13 PM, "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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140106/8798cd72/attachment.html>


More information about the Haskell-Cafe mailing list