~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to src/prototyping/nameless/Main.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
module Main where
3
 
 
4
 
import Control.Applicative
5
 
import System.Environment
6
 
 
7
 
import Lam.Par
8
 
import Lam.Lex
9
 
import Lam.Layout
10
 
import Lam.Abs
11
 
import Lam.ErrM
12
 
import Lam.Print
13
 
 
14
 
import Syntax
15
 
import TypeChecker
16
 
import Stack
17
 
 
18
 
parse :: String -> Err Prog
19
 
parse s = pProg $ resolveLayout True $ myLexer s
20
 
 
21
 
parseFile :: FilePath -> IO (Err Prog)
22
 
parseFile file = parse <$> readFile file
23
 
 
24
 
goFile :: FilePath -> IO ()
25
 
goFile file = do
26
 
  r <- parseFile file
27
 
  case r of
28
 
    Bad err -> putStrLn $ "Error:\n" ++ err
29
 
    Ok p    -> do
30
 
      print p
31
 
      putStrLn "--- Type checked ---"
32
 
      case runTCM emptyEnv $ checkProgram p of
33
 
        Left err -> putStrLn $ "ERROR:\n" ++ err
34
 
        Right ds -> mapM_ (putStrLn . printTree . toAbstractDecl) ds
35
 
 
36
 
main = do
37
 
  args <- getArgs
38
 
  case args of
39
 
    [file]  -> goFile file
40
 
    _       -> putStrLn "File argument missing."