[Haskell] hs2lhs

Derek Elkins ddarius at hotpop.com
Sat Feb 14 13:54:45 EST 2004


On Sat, 14 Feb 2004 15:25:07 -0000
"Stenio" <stenio at uesb.br> wrote:

> I need to convert some scripts (hs) to lhs (literate script) and lhs
> (literate script) to hs using GHC. Can someone help me.

GHC comes with an unlit program that will convert lhs to hs files,
there's probably also some flag you can give to GHC to have it spit out
the .hs file after processing it.  As for hs to lhs, there doesn't seem
much point nor is tool support necessary.  You can either add
\begin{code} \end{code} to the beginning and ending of the file
respectively to get a LaTeX style lhs file or one way or another (e.g.
:%s/^/> / in vim) get Bird style lhs files.  You can make such a
program in one line of Haskell,
main = getContents >>= mapM_ (putStrLn . ("> "++)) . lines



More information about the Haskell mailing list