[Haskell-cafe] Re: is there a way to pretty print a module?
Simon Richard Clarkstone
simon.clarkstone at gmail.com
Sun Nov 2 14:34:02 EST 2008
Anatoly Yakovenko wrote:
>>> is there a way to pretty print a module?
>>> module Main where
>>> import Language.Haskell.TH
>>> main = do
>>> print $ pprint Main
>> haskell-src should be able to do that.
> I think haskell-src requires you to read the module at run time. I
> want to embed the contents of the module in my program. Basically a
> program that can print itself.
This is rather like the idea of a quine; a program the prints itself out
without referring directly to its own source code. The usual Haskell
putStrLn$(\s->s++show s)"putStrLn$(\\s->s++show s)"
If merely returning the source code is enough then you can do:
(\s->s++show s)"(\\s->s++show s)"
It could be more elegant if \ weren't both lambda and string escape.
More information about the Haskell-Cafe