module Main where

import Parser

import Control.Monad.Trans
import System.Console.Haskeline

process line = do
  let res = parseTopLevel line
  case res of
    Left err -> print err
    Right ex -> mapM_ print ex

main = runInputT defaultSettings loop
  where
    loop = do
      minput <- getInputLine "ready> "
      case minput of
        Nothing -> outputStrLn "Goodbye."
        Just input -> (liftIO $ process input) >> loop
