[Haskell-cafe] Cabal and Strings and CPP

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Jul 29 06:14:37 EDT 2008

"Philip Weaver" <philip.weaver at gmail.com> wrote:

> I'm trying to use CPP-defined strings in a Haskell module, like this:
>    main :: IO ()
>    main = putStrLn FOO
> This of course will not work:
>    ghc -DFOO="hello world" --make Main.hs -o test

Have you tried using ANSI cpp's stringification operator?

    {-# LANGUAGE CPP #-}
    #define STRING(bar) #bar
    main :: IO ()
    main = putStrLn FOO

  ghc -DFOO="STRING(hello world)" --make Main.hs -o test


More information about the Haskell-Cafe mailing list