@@ -5,14 +5,44 @@ module Idris.AbsSyntax where
5import Core.TT
5import Core.TT
6import Core.Evaluate
6import Core.Evaluate
8+import Control.Monad.State
11+data IOption = Logging
8data IState = IState { tt_ctxt :: Context,
14data IState = IState { tt_ctxt :: Context,
9− tt_infixes :: [FixDecl]
15+ idris_infixes :: [FixDecl],
16+ idris_implicits :: Ctxt [Name],
18+ idris_options :: [IOption]
12−{- Plan:
21+idrisInit = IState emptyContext [] emptyContext "" []
13− Treat it as a theorem prover - one definition at a time, parse, elaborate,
22+
14− and add to context. Since elaboration can be affected by definitions we've
23+-- The monad for the main REPL - reading and processing files and updating
15− added (e.g. plicity) -}
24+-- global state (hence the IO inner monad).
25+type Idris a = StateT IState IO a
27+iputStrLn :: String -> Idris ()
28+iputStrLn = lift.putStrLn
30+setOpt :: IOption -> Bool -> Idris ()
31+setOpt o True = do i <- get
32+ put (i { idris_options = nub (o : idris_options i) })
33+setOpt o False = do i <- get
34+ put (i { idris_options = idris_options i \\ [o] })
36+iLOG :: String -> Idris ()
37+iLOG str = do i <- get
38+ when (Logging `elem` idris_options i)
39+ $ do lift (putStrLn str)
40+ put (i { idris_log = idris_log i ++ str ++ "\n" } )
42+-- Commands in the REPL
17-- Parsed declarations
47-- Parsed declarations