2
{-# LANGUAGE PatternGuards #-}
4
3
{-| Agda main module.
6
5
module Agda.Main where
8
7
import Control.Monad.State
9
import Control.Monad.Error
10
8
import Control.Applicative
12
10
import qualified Data.List as List
39
37
import Agda.Compiler.Epic.Compiler as Epic
40
38
import Agda.Compiler.JS.Compiler as JS
40
import Agda.Utils.Lens
42
41
import Agda.Utils.Monad
42
import Agda.Utils.Pretty (prettyShow)
43
import Agda.Utils.String
43
44
import qualified Agda.Utils.Trie as Trie
46
47
import Agda.Version
49
import Agda.Utils.Except ( MonadError(catchError, throwError) )
50
import Agda.Utils.Impossible
48
52
#include "undefined.h"
49
import Agda.Utils.Impossible
51
54
-- | The main function
83
86
map (Boxes.text . showAccount) $
85
88
-- Second column is times.
86
-- CPU times are in pico seconds, convert to milliseconds.
87
89
col2 = Boxes.vcat Boxes.right $
88
map (Boxes.text . (++ " ms") . show . (`div` 1000000000)) $
90
map (Boxes.text . prettyShow) $
90
92
table = Boxes.hsep 1 Boxes.left [col1, col2]
91
93
reportBenchmarkingLn $ Boxes.render table
95
-- Print accumulated statistics.
96
printStatistics 20 Nothing =<< use lensAccumStatistics
93
99
checkFile :: TCM ()
130
136
unsolvedOK <- optAllowUnsolved <$> pragmaOptions
138
-- Reported unsolved problems as error unless unsolvedOK.
139
-- An interface is only generated if NoWarnings.
132
140
result <- case mw of
133
-- we get here if there are unfilled interaction
134
-- points that have been solved by unification
135
SomeWarnings (Warnings [] [] []) -> return Nothing
136
SomeWarnings (Warnings _ unsolved@(_:_) _)
137
| not unsolvedOK -> typeError $ UnsolvedMetas unsolved
138
SomeWarnings (Warnings _ _ unsolved@(_:_))
139
| not unsolvedOK -> typeError $ UnsolvedConstraints unsolved
140
SomeWarnings (Warnings termErrs@(_:_) _ _) ->
141
typeError $ TerminationCheckFailed termErrs
142
SomeWarnings _ -> return Nothing
143
NoWarnings -> return $ Just i
142
SomeWarnings (Warnings w@(_:_) _)
143
| not unsolvedOK -> typeError $ UnsolvedMetas w
144
-- Unsolved constraints.
145
SomeWarnings (Warnings _ w@(_:_))
146
| not unsolvedOK -> typeError $ UnsolvedConstraints w
147
-- Unsolved metas, unsolved constraints, or
148
-- interaction points left whose metas have been solved
149
-- automatically. (See Issue 1296).
150
SomeWarnings (Warnings _ _) -> return Nothing
151
NoWarnings -> return $ Just i
145
153
whenM (optGenerateHTML <$> commandLineOptions) $