[Haskell-cafe] Re: is there a way to pretty print a module?

Anatoly Yakovenko aeyakovenko at gmail.com
Thu Oct 30 19:42:45 EDT 2008


i guess am missing something:

$ cat ./test.hs
 {-# LANGUAGE TemplateHaskell#-}
module Main where

import Language.Haskell.TH
import qualified Data.ByteString as BS

embedFile :: FilePath -> Q BS.ByteString
embedFile ff = runIO $ BS.readFile ff


main = do
   me <- runQ $ embedFile "./test.hs"
   print me

$ ghc --make test.hs
[1 of 1] Compiling Main             ( test.hs, test.o )
Linking test ...

 $ ./test
" {-# LANGUAGE TemplateHaskell#-}\nmodule Main where\n\nimport
Language.Haskell.TH\nimport qualified Data.ByteString as
BS\n\nembedFile :: FilePath -> Q BS.ByteString\nembedFile ff = runIO $
BS.readFile ff\n\n\nmain = do\n   me <- runQ $ embedFile
\"./test.hs\"\n   print me\n\n"

$ mv test.hs test.hs.old

$ ./test
test: ./test.hs: openBinaryFile: does not exist (No such file or directory)

i was hoping test.hs would become part of the executable.


More information about the Haskell-Cafe mailing list