module Main import Quox.Syntax import Quox.Parser import Quox.Definition import Quox.Pretty import System import Data.IORef import Data.SortedSet import Control.Eff import Text.PrettyPrint.Prettyprinter.Render.Terminal export die : Doc HL -> IO a die err = do putDoc $ termHL <$> err; exitFailure export main : IO () main = do seen <- newIORef SortedSet.empty defs <- newIORef SortedMap.empty suf <- newIORef $ the Nat 0 for_ (drop 1 !getArgs) $ \file => do putStrLn "checking \{file}" Right res <- fromParserIO ["."] seen suf defs $ loadProcessFile noLoc file | Left err => die $ prettyError True True err for_ res $ \(name, def) => do putDoc $ map termHL $ nest 2 $ sep [hsep [hcat [pretty0 True def.qty.fst, dotD, hl Free (pretty0 True name)], colonD], prettyTerm True [<] [<] def.type] ----------------------------------- private text : PrettyOpts -> List String text _ = ["", #" ___ ___ _____ __ __"#, #"/ _ `/ // / _ \\ \ /"#, #"\_, /\_,_/\___/_\_\"#, #" /_/"#, ""] private qtuwu : PrettyOpts -> List String qtuwu opts = if opts.unicode then [#" ___,-´⎠ "#, #"(·`──´ ◡ -´⎠"#, #" \/\/──´⎞/`──´ "#, #" ⎜⎟───,-₎ ⎞ "#, #" ⎝⎠ (‾‾) ⎟ "#, #" (‾‾‾) ⎟ "#] else [#" ___,-´/ "#, #"(.`--´ u -´/"#, #" \/\/--´|/`--´ "#, #" ||---,-, \ "#, #" `´ (--) | "#, #" (---) | "#] private join1 : PrettyOpts -> String -> String -> String join1 opts l r = if opts.color then " " <+> show (colored Green l) <+> " " <+> show (colored Magenta r) else " " <+> l <+> " " <+> r export banner : PrettyOpts -> String banner opts = unlines $ zipWith (join1 opts) (qtuwu opts) (text opts)