
jmvilaca:
Hi all,
Is there a simple tool or command to remove all comments from a Haskell file, i.e. something that outputs the input file but without any comments on it?
Using Language.Haskell, such a program is almost trivial: -- -- strip comments from haskell source -- {- the main module -} import Language.Haskell.Parser import Language.Haskell.Pretty main = interact $ \s -> case parseModule s of ParseFailed loc str -> (show loc) ++ "\n" ParseOk m -> (prettyPrint m) ++ "\n" And running this program on itself: $ runhaskell A.hs < A.hs module Main (main) where import Language.Haskell.Parser import Language.Haskell.Pretty main = interact $ \ s -> case parseModule s of ParseFailed loc str -> (show loc) ++ "\n" ParseOk m -> (prettyPrint m) ++ "\n" Hehe, it also pretty prints :-) -- Don