I\'m looking for a tool that can pretty-print (AKA tidy or beautify) source code in as many languages as possible. Those I\'m particularly keen on include:
For Haskell, I have this in ~/bin/pp.hs
:
#!/usr/bin/env runhaskell
module Main (main) where
import Language.Haskell.Parser
import Language.Haskell.Pretty
import System.Environment
pp f = case parseModule f
of ParseOk m -> prettyPrint m
a -> show a
main = do args <- getArgs
mapM_ (>>= putStrLn . pp) $
if null args then [getContents] else map readFile args
In Vim, :set equalprg=~/bin/pp.hs
, select a region, hit =
, and boom, it gets prettified.
Okay, it's not very general. But I figure it has a small chance of helping somebody if I add it here.