Is it possible to use Language.Haskell to print a program with comments preserved? That might be useful for refactoring.
Not that Language.Haskell isn't already cool enough, if the answer is "no", of course. Frederik On Fri, May 04, 2007 at 10:33:07AM +1000, Donald Bruce Stewart wrote: > 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 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- http://ofb.net/~frederik/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe