[Haskell-cafe] Template haskell and the dependencies of the generated executable

Aldo Davide aldodavide at gmx.com
Tue Mar 31 16:37:29 UTC 2015


When I use template haskell to generate some code at compile time and splice it in my program, the generated executable still depends on template haskell (in case of -dynamic), or the Template haskell library is included in my executable (in the case of -static). Isn't that unnecessary?

For example. Suppose that I use the almost trivial raw-strings-qq package to implement a hello world program:

    {-# LANGUAGE QuasiQuotes #-}
    import Text.RawString.QQ (r)
    main = putStrLn [r|Bonjour tout le monde|]

Then the r quasi quoter runs at compile time and generates a string literal. So basically, the program that gets compiled is the following:

    main = putStrLn "Bonjour tout le monde"

Despite that template haskell is only used at compile time, the generated executable (compiled with the -dynamic flags) depends on the following libraries:

    libHSarray-0.5.0.0-ghc7.8.4.so
    libHScontainers-0.5.5.1-ghc7.8.4.so
    libHSdeepseq-1.3.0.2-ghc7.8.4.so
    libHSpretty-1.1.1.1-ghc7.8.4.so
    libHSraw-strings-qq-1.0.2-ghc7.8.4.so
    libHStemplate-haskell-2.9.0.0-ghc7.8.4.so

in addition to the ones that the non template haskell version of the program depends.

Shouldn't ghc avoid that?


More information about the Haskell-Cafe mailing list