Skip to content

Instantly share code, notes, and snippets.

@yamadapc
Created June 28, 2016 05:03
Show Gist options
  • Save yamadapc/6cf0787e6c8bcb92ec682a2f60d5405f to your computer and use it in GitHub Desktop.
Save yamadapc/6cf0787e6c8bcb92ec682a2f60d5405f to your computer and use it in GitHub Desktop.
import Control.Arrow ((>>>))
import Language.Haskell.Exts
import System.Environment
import Text.Show.Pretty (ppShow)
headMaybe (x:_) = Just x
headMaybe _ = Nothing
main = do
(a:_) <- getArgs
c <- readFile a :: IO String
let process :: String -> String
process =
unlines .
filter (headMaybe >>> maybe False (/= '#')) .
lines
c' = process c
let ParseOk r = parseFileContents c'
putStrLn $ ppShow r
putStrLn $ prettyPrint r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment