[Haskell-cafe] Re: Layout to non-layout code
Maurício
briqueabraque at yahoo.com
Sat Nov 3 01:59:21 EDT 2007
>> Hi,
>>
>> (...)
>>
>> So, I wonder: would it be possible to implement
>> a feature in, say, ghc, that would take code
>> from input and output the same code with layout
>> replaced by delimiting characters? (...)
>
>
> ghc -ddump-parsed does this, iirc.
>
> So does the Language.Haskell library. See this
> wiki page on indenting for more ideas,
>
> http://haskell.org/haskellwiki/Indent
>
> -- Don
I was impressed after your tip about
'Language.Haskell'. In a few minutes, I got my
dream Haskell formatter. Here it is, parsed by
itself. Thanks for your tip.
module Main (Main.main) where
{ import System.IO;
import Language.Haskell.Parser;
import Language.Haskell.Pretty;
import Text.PrettyPrint.HughesPJ;
main :: IO ();
main
= do
{ program <- getContents;
ParseOk parse <- return $
parseModule program;
estilo <- return $ Style PageMode 50 1.0;
modo <- return $
PPHsMode 0 0 0 0 0 3 True
PPSemiColon
False
True;
putStrLn $
prettyPrintStyleMode estilo modo
parse}}
More information about the Haskell-Cafe
mailing list