module Main where

import PTS.Quote
import PTS.Parser
import PTS.Core
import PTS.Pretty
import PTS.AST

import Control.Monad.Error
import Tools.Errors (runErrorsT)
import Parametric.Error (showErrors, annotateCode)

main' = do
  text <- liftIO getContents
  let code = lines text
  e <- parseTerm fomegastarConstants "<stdin>" text
  t <- annotateCode code $ typecheck fomegastar 0 [] e
  k <- annotateCode code $ typecheck fomegastar 0 [] t
  case normalform k of
    Const "*" -> do q <- annotateCode code $ quotequote 0 [] e
                    liftIO (putStrLn (multiLine 80 q))
    _ -> do liftIO (putStrLn (multiLine 80 e))

main = runErrorsT $ main' `catchError` \e -> liftIO $ putStrLn (showErrors e)
