
patc:
Is there an equivalent of an "indent" program for haskell? I have a bit of code I want to clean up ...
You could run your code through ghc, with -ddump-parsed turned on. Then with a little bit of sed magic, you could recover the original code Before: $ cat B.hs main = do { ;print (f 10) ; print (f 20) ;print (f 0xdeadbeef) } f x = sqrt ( fromIntegral (x * 10133123 `mod` 1231111121 :: Int )) After: $ ghc -fno-code -ddump-parsed B.hs ==================== Parser ==================== main = do print (f 10) print (f 20) print (f 3735928559) f x = sqrt (fromIntegral ((x * 10133123) `mod` 1231111121 :: Int)) Postprocess: $ ghc -fno-code -ddump-parsed B.hs | sed '/^===/d' main = do print (f 10) print (f 20) print (f 3735928559) f x = sqrt (fromIntegral ((x * 10133123) `mod` 1231111121 :: Int)) Yay! Now, I suspect there may be actually be (not well publicised) tools for this. If there are, they should go on the haskell.org "Libraries and tools" page. -- Don
participants (1)
-
dons@cse.unsw.edu.au