Skip to content

Instantly share code, notes, and snippets.

@berberman
Last active June 5, 2022 20:11
Show Gist options
  • Select an option

  • Save berberman/d550c7406b65244d523a61a781cc7136 to your computer and use it in GitHub Desktop.

Select an option

Save berberman/d550c7406b65244d523a61a781cc7136 to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell --pure -i "runghc -- -package --ghc-arg=ghc" -p "haskellPackages.ghcWithPackages (p: with p; [ ghc-exactprint pretty-simple ])"
import GHC.Hs.Dump
import Language.Haskell.GHC.ExactPrint.Parsers
import GHC.Utils.Outputable
import System.Environment
import Text.Pretty.Simple
main :: IO ()
main = do
args <- getArgs
case args of
[file] -> do
Right (anns, pm) <- parseModule file
putStrLn . showSDocUnsafe $ showAstData NoBlankSrcSpan pm
pPrint anns
_ -> putStrLn "Expect one arg."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment