PrettyInterface.hs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {-# LANGUAGE ScopedTypeVariables #-}
  2. -- | Pretty-print contents of an interface file.
  3. module Main where
  4. ------------------------------------------------------------------------------
  5. -- Haskell imports
  6. import Control.Monad.IO.Class ( MonadIO(liftIO) )
  7. import Data.Foldable
  8. import qualified Data.HashMap.Strict as HashMap
  9. ------------------------------------------------------------------------------
  10. -- Agda library imports
  11. import Agda.Interaction.FindFile ( SourceFile(..) )
  12. import Agda.Interaction.Imports ( typeCheckMain, Mode(TypeCheck), parseSource, CheckResult(CheckResult), crInterface )
  13. import Agda.Interaction.Options ( defaultOptions )
  14. -- import Agda.Syntax.Translation.InternalToAbstract ( reify )
  15. -- import Agda.Syntax.Translation.AbstractToConcrete ()
  16. import Agda.TypeChecking.Monad
  17. import Agda.TypeChecking.Pretty
  18. import Agda.Utils.FileName
  19. import Agda.Utils.Pretty (render)
  20. ------------------------------------------------------------------------------
  21. main :: IO ()
  22. main = do
  23. _ <- liftIO $ runTCMTop mainTCM
  24. return ()
  25. mainTCM :: TCM ()
  26. mainTCM = do
  27. setCommandLineOptions defaultOptions
  28. f <- liftIO $ SourceFile <$> absolute "PrettyInterface.agda"
  29. CheckResult { crInterface = i } <- typeCheckMain TypeCheck =<< parseSource f
  30. compilerMain i
  31. compilerMain :: Interface -> TCM ()
  32. compilerMain i = withScope_ (iInsideScope i) $ do -- withShowAllArguments $ disableDisplayForms $ do
  33. let (Sig _secs defs _rews) = iSignature i
  34. forM_ (HashMap.toList defs) $ \ (q, def) -> do
  35. let t = defType def
  36. doc <- prettyTCM q <+> text ":" <+> prettyTCM t
  37. liftIO $ putStrLn $ render doc
  38. -- forM_ (HashMap.toList defs) $ \ (q, def) -> do
  39. -- let t = defType def
  40. -- ast <- reify t
  41. -- liftIO $ putStrLn $ show q ++ " : " ++ show t
  42. -- return $ const () ast