2018-11-25 16:34:28 +03:00
|
|
|
module Main (main) where
|
|
|
|
|
2018-12-08 13:34:26 +03:00
|
|
|
import Control.Monad
|
|
|
|
import Ormolu.Parser
|
2018-12-08 17:39:42 +03:00
|
|
|
import Ormolu.Printer
|
2018-12-08 13:34:26 +03:00
|
|
|
import System.Environment (getArgs)
|
2019-01-30 20:36:52 +03:00
|
|
|
import qualified Data.Text.IO as TIO
|
2018-12-08 13:34:26 +03:00
|
|
|
import qualified Outputable as GHC
|
|
|
|
|
2018-11-25 16:34:28 +03:00
|
|
|
main :: IO ()
|
2018-12-08 13:34:26 +03:00
|
|
|
main = do
|
|
|
|
(path:_) <- getArgs
|
|
|
|
input <- readFile path
|
2019-01-30 20:36:52 +03:00
|
|
|
|
2018-12-08 13:34:26 +03:00
|
|
|
(ws, r) <- parseModule [] path input
|
|
|
|
unless (null ws) $
|
|
|
|
putStrLn "dynamic option warnings:"
|
|
|
|
case r of
|
|
|
|
Left (srcSpan, err) -> do
|
|
|
|
putStrLn (showOutputable srcSpan)
|
|
|
|
putStrLn err
|
|
|
|
Right (anns, parsedModule) -> do
|
|
|
|
putStrLn "\nannotations:\n"
|
|
|
|
putStrLn (showOutputable anns)
|
|
|
|
putStrLn "\nparsed module:\n"
|
|
|
|
putStrLn (showOutputable parsedModule)
|
2019-01-30 20:36:52 +03:00
|
|
|
TIO.putStr (printModule anns parsedModule)
|
2018-12-08 17:39:42 +03:00
|
|
|
|
2018-12-08 13:34:26 +03:00
|
|
|
showOutputable :: GHC.Outputable o => o -> String
|
|
|
|
showOutputable = GHC.showSDocUnsafe . GHC.ppr
|