@@ -42,7 +42,7 @@ import Idris.Elab.Value
4242import Version_idris (gitHash)
4343import Util.System
4444import Util.DynamicLinker
45−import Util.Net (listenOnLocalhost)
45+import Util.Net (listenOnLocalhost, listenOnLocalhostAnyPort)
4646import Util.Pretty hiding ((</>))
4747
4848import Idris.Core.Evaluate
@@ -91,6 +91,8 @@ import Data.Word (Word)
9191import Data.Either (partitionEithers)
9292import Control.DeepSeq
9393
94+import Numeric ( readHex )
95+
9496import Debug.Trace
9597
9698-- | Run the REPL
@@ -149,7 +151,7 @@ startServer orig fn_in = do tid <- runIO $ forkOS serverLoop
149151 -- TODO: option for port number
150152 serverLoop = withSocketsDo $
151153 do sock <- listenOnLocalhost $ PortNumber 4294
152− loop fn orig sock
154+ loop fn orig { idris_colourRepl = False } sock
153155
154156 fn = case fn_in of
155157 (f:_) -> f
@@ -159,7 +161,10 @@ startServer orig fn_in = do tid <- runIO $ forkOS serverLoop
159161 = do (h,_,_) <- accept sock
160162 hSetEncoding h utf8
161163 cmd <- hGetLine h
162− (ist', fn) <- processNetCmd orig ist h fn cmd
164+ let isth = case idris_outputmode ist of
165+ RawOutput _ -> ist {idris_outputmode = RawOutput h}
166+ IdeSlave n _ -> ist {idris_outputmode = IdeSlave n h}
167+ (ist', fn) <- processNetCmd orig isth h fn cmd
163168 hClose h
164169 loop fn ist' sock
165170
@@ -185,12 +190,18 @@ processNetCmd orig i h fn cmd
185190 setOutH h
186191 setQuiet True
187192 setVerbose False
188− mods <- loadInputs h [f] toline
193+ mods <- loadInputs [f] toline
189194 ist <- getIState
190195 return (ist, f)
191− processNet fn c = do process h fn c
196+ processNet fn c = do process fn c
192197 ist <- getIState
193198 return (ist, fn)
199+ setOutH :: Handle -> Idris ()
200+ setOutH h =
201+ do ist <- getIState
202+ putIState $ case idris_outputmode ist of
203+ RawOutput _ -> ist {idris_outputmode = RawOutput h}
204+ IdeSlave n _ -> ist {idris_outputmode = IdeSlave n h}
194205
195206-- | Run a command on the server on localhost
196207runClient :: String -> IO ()
@@ -206,55 +217,73 @@ runClient str = withSocketsDo $ do
206217 else do l <- hGetLine h
207218 hGetResp (acc ++ l ++ "\n") h
208219
220+initIdeslaveSocket :: IO Handle
221+initIdeslaveSocket = do
222+ (sock, port) <- listenOnLocalhostAnyPort
223+ putStrLn $ show port
224+ (h, _, _) <- accept sock
225+ hSetEncoding h utf8
226+ return h
227+
209228-- | Run the IdeSlave
210−ideslaveStart :: IState -> [FilePath] -> Idris ()
211−ideslaveStart orig mods
212− = do i <- getIState
229+ideslaveStart :: Bool -> IState -> [FilePath] -> Idris ()
230+ideslaveStart s orig mods
231+ = do h <- runIO $ if s then initIdeslaveSocket else return stdout
232+ setIdeSlave True h
233+ i <- getIState
213234 case idris_outputmode i of
214− IdeSlave n ->
215− when (mods /= []) (do isetPrompt (mkPrompt mods))
216− ideslave orig mods
217−
218−
219−ideslave :: IState -> [FilePath] -> Idris ()
220−ideslave orig mods
235+ IdeSlave n h ->
236+ do runIO $ hPutStrLn h $ IdeSlave.convSExp "protocol-version" IdeSlave.ideSlaveEpoch n
237+ case mods of
238+ a:_ -> runIdeSlaveCommand h n i "" [] (IdeSlave.LoadFile a Nothing)
239+ _ -> return ()
240+ ideslave h orig mods
241+
242+ideslave :: Handle -> IState -> [FilePath] -> Idris ()
243+ideslave h orig mods
221244 = do idrisCatch
222− (do l <- runIO $ getLine
245+ (do let inh = if h == stdout then stdin else h
246+ len' <- runIO $ IdeSlave.getLen inh
247+ len <- case len' of
248+ Left err -> ierror err
249+ Right n -> return n
250+ l <- runIO $ IdeSlave.getNChar inh len ""
223251 (sexp, id) <- case IdeSlave.parseMessage l of
224252 Left err -> ierror err
225253 Right (sexp, id) -> return (sexp, id)
226254 i <- getIState
227− putIState $ i { idris_outputmode = (IdeSlave id) }
255+ putIState $ i { idris_outputmode = (IdeSlave id h) }
228256 idrisCatch -- to report correct id back!
229257 (do let fn = case mods of
230258 (f:_) -> f
231− _ -> ""
259+ _ -> ""
232260 case IdeSlave.sexpToCommand sexp of
233− Just cmd -> runIdeSlaveCommand id orig fn mods cmd
261+ Just cmd -> runIdeSlaveCommand h id orig fn mods cmd
234262 Nothing -> iPrintError "did not understand" )
235263 (\e -> do iPrintError $ show e))
236264 (\e -> do iPrintError $ show e)
237− ideslave orig mods
265+ ideslave h orig mods
238266
239267-- | Run IDESlave commands
240−runIdeSlaveCommand :: Integer -- ^^ The continuation ID for the client
268+runIdeSlaveCommand :: Handle -- ^^ The handle for communication
269+ -> Integer -- ^^ The continuation ID for the client
241270 -> IState -- ^^ The original IState
242271 -> FilePath -- ^^ The current open file
243272 -> [FilePath] -- ^^ The currently loaded modules
244273 -> IdeSlave.IdeSlaveCommand -- ^^ The command to process
245274 -> Idris ()
246−runIdeSlaveCommand id orig fn mods (IdeSlave.Interpret cmd) =
275+runIdeSlaveCommand h id orig fn mods (IdeSlave.Interpret cmd) =
247276 do c <- colourise
248277 i <- getIState
249278 case parseCmd i "(input)" cmd of
250279 Failure err -> iPrintError $ show (fixColour c err)
251280 Success (Prove n') ->
252281 idrisCatch
253− (do process stdout fn (Prove n')
282+ (do process fn (Prove n')
254283 isetPrompt (mkPrompt mods)
255284 case idris_outputmode i of
256− IdeSlave n -> -- signal completion of proof to ide
257− runIO . hPutStrLn stdout $
285+ IdeSlave n h -> -- signal completion of proof to ide
286+ runIO . hPutStrLn h $
258287 IdeSlave.convSExp "return"
259288 (IdeSlave.SymbolAtom "ok", "")
260289 n
@@ -262,26 +291,26 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.Interpret cmd) =
262291 (\e -> do ist <- getIState
263292 isetPrompt (mkPrompt mods)
264293 case idris_outputmode i of
265− IdeSlave n ->
266− runIO . hPutStrLn stdout $
294+ IdeSlave n h ->
295+ runIO . hPutStrLn h $
267296 IdeSlave.convSExp "abandon-proof" "Abandoned" n
268297 _ -> return ()
269− ihRenderError stdout $ pprintErr ist e)
298+ iRenderError $ pprintErr ist e)
270299 Success cmd -> idrisCatch
271300 (ideslaveProcess fn cmd)
272− (\e -> getIState >>= ihRenderError stdout . flip pprintErr e)
273−runIdeSlaveCommand id orig fn mods (IdeSlave.REPLCompletions str) =
301+ (\e -> getIState >>= iRenderError . flip pprintErr e)
302+runIdeSlaveCommand h id orig fn mods (IdeSlave.REPLCompletions str) =
274303 do (unused, compls) <- replCompletion (reverse str, "")
275304 let good = IdeSlave.SexpList [IdeSlave.SymbolAtom "ok",
276305 IdeSlave.toSExp (map replacement compls,
277306 reverse unused)]
278− runIO $ putStrLn $ IdeSlave.convSExp "return" good id
279−runIdeSlaveCommand id orig fn mods (IdeSlave.LoadFile filename toline) =
307+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" good id
308+runIdeSlaveCommand h id orig fn mods (IdeSlave.LoadFile filename toline) =
280309 do i <- getIState
281310 clearErr
282311 putIState (orig { idris_options = idris_options i,
283− idris_outputmode = (IdeSlave id) })
284− loadInputs stdout [filename] toline
312+ idris_outputmode = (IdeSlave id h) })
313+ loadInputs [filename] toline
285314 isetPrompt (mkPrompt [filename])
286315 -- Report either success or failure
287316 i <- getIState
@@ -291,45 +320,45 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.LoadFile filename toline) =
291320 (\fc -> IdeSlave.SexpList [IdeSlave.SymbolAtom "ok",
292321 IdeSlave.toSExp fc])
293322 (idris_parsedSpan i)
294− in runIO . putStrLn $ IdeSlave.convSExp "return" msg id
323+ in runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
295324 Just x -> iPrintError $ "didn't load " ++ filename
296− ideslave orig [filename]
297−runIdeSlaveCommand id orig fn mods (IdeSlave.TypeOf name) =
325+ ideslave h orig [filename]
326+runIdeSlaveCommand h id orig fn mods (IdeSlave.TypeOf name) =
298327 case splitName name of
299328 Left err -> iPrintError err
300− Right n -> process stdout "(ideslave)"
329+ Right n -> process "(ideslave)"
301330 (Check (PRef (FC "(ideslave)" (0,0) (0,0)) n))
302331 where splitName :: String -> Either String Name
303332 splitName s = case reverse $ splitOn "." s of
304333 [] -> Left ("Didn't understand name '" ++ s ++ "'")
305334 [n] -> Right $ sUN n
306335 (n:ns) -> Right $ sNS (sUN n) ns
307−runIdeSlaveCommand id orig fn mods (IdeSlave.DocsFor name) =
336+runIdeSlaveCommand h id orig fn mods (IdeSlave.DocsFor name) =
308337 case parseConst orig name of
309− Success c -> process stdout "(ideslave)" (DocStr (Right c))
338+ Success c -> process "(ideslave)" (DocStr (Right c))
310339 Failure _ ->
311340 case splitName name of
312341 Left err -> iPrintError err
313− Right n -> process stdout "(ideslave)" (DocStr (Left n))
314−runIdeSlaveCommand id orig fn mods (IdeSlave.CaseSplit line name) =
315− process stdout fn (CaseSplitAt False line (sUN name))
316−runIdeSlaveCommand id orig fn mods (IdeSlave.AddClause line name) =
317− process stdout fn (AddClauseFrom False line (sUN name))
318−runIdeSlaveCommand id orig fn mods (IdeSlave.AddProofClause line name) =
319− process stdout fn (AddProofClauseFrom False line (sUN name))
320−runIdeSlaveCommand id orig fn mods (IdeSlave.AddMissing line name) =
321− process stdout fn (AddMissing False line (sUN name))
322−runIdeSlaveCommand id orig fn mods (IdeSlave.MakeWithBlock line name) =
323− process stdout fn (MakeWith False line (sUN name))
324−runIdeSlaveCommand id orig fn mods (IdeSlave.ProofSearch r line name hints depth) =
325− doProofSearch stdout fn False r line (sUN name) (map sUN hints) depth
326−runIdeSlaveCommand id orig fn mods (IdeSlave.MakeLemma line name) =
342+ Right n -> process "(ideslave)" (DocStr (Left n))
343+runIdeSlaveCommand h id orig fn mods (IdeSlave.CaseSplit line name) =
344+ process fn (CaseSplitAt False line (sUN name))
345+runIdeSlaveCommand h id orig fn mods (IdeSlave.AddClause line name) =
346+ process fn (AddClauseFrom False line (sUN name))
347+runIdeSlaveCommand h id orig fn mods (IdeSlave.AddProofClause line name) =
348+ process fn (AddProofClauseFrom False line (sUN name))
349+runIdeSlaveCommand h id orig fn mods (IdeSlave.AddMissing line name) =
350+ process fn (AddMissing False line (sUN name))
351+runIdeSlaveCommand h id orig fn mods (IdeSlave.MakeWithBlock line name) =
352+ process fn (MakeWith False line (sUN name))
353+runIdeSlaveCommand h id orig fn mods (IdeSlave.ProofSearch r line name hints depth) =
354+ doProofSearch fn False r line (sUN name) (map sUN hints) depth
355+runIdeSlaveCommand h id orig fn mods (IdeSlave.MakeLemma line name) =
327356 case splitName name of
328357 Left err -> iPrintError err
329− Right n -> process stdout fn (MakeLemma False line n)
330−runIdeSlaveCommand id orig fn mods (IdeSlave.Apropos a) =
331− process stdout fn (Apropos a)
332−runIdeSlaveCommand id orig fn mods (IdeSlave.GetOpts) =
358+ Right n -> process fn (MakeLemma False line n)
359+runIdeSlaveCommand h id orig fn mods (IdeSlave.Apropos a) =
360+ process fn (Apropos a)
361+runIdeSlaveCommand h id orig fn mods (IdeSlave.GetOpts) =
333362 do ist <- getIState
334363 let opts = idris_options ist
335364 let impshow = opt_showimp opts
@@ -337,16 +366,16 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.GetOpts) =
337366 let options = (IdeSlave.SymbolAtom "ok",
338367 [(IdeSlave.SymbolAtom "show-implicits", impshow),
339368 (IdeSlave.SymbolAtom "error-context", errCtxt)])
340− runIO . putStrLn $ IdeSlave.convSExp "return" options id
341−runIdeSlaveCommand id orig fn mods (IdeSlave.SetOpt IdeSlave.ShowImpl b) =
369+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" options id
370+runIdeSlaveCommand h id orig fn mods (IdeSlave.SetOpt IdeSlave.ShowImpl b) =
342371 do setImpShow b
343372 let msg = (IdeSlave.SymbolAtom "ok", b)
344− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
345−runIdeSlaveCommand id orig fn mods (IdeSlave.SetOpt IdeSlave.ErrContext b) =
373+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
374+runIdeSlaveCommand h id orig fn mods (IdeSlave.SetOpt IdeSlave.ErrContext b) =
346375 do setErrContext b
347376 let msg = (IdeSlave.SymbolAtom "ok", b)
348− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
349−runIdeSlaveCommand id orig fn mods (IdeSlave.Metavariables cols) =
377+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
378+runIdeSlaveCommand h id orig fn mods (IdeSlave.Metavariables cols) =
350379 do ist <- getIState
351380 let mvs = reverse $ map fst (idris_metavars ist) \\ primDefs
352381 let ppo = ppOptionIst ist
@@ -362,7 +391,7 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.Metavariables cols) =
362391 (zip bnds hs),
363392 render ist bnd c pc))
364393 splitMvs
365− runIO . putStrLn $
394+ runIO . hPutStrLn h $
366395 IdeSlave.convSExp "return" (IdeSlave.SymbolAtom "ok", mvOutput) id
367396 where mapPair f g xs = zip (map (f . fst) xs) (map (g . snd) xs)
368397 mapSnd f xs = zip (map fst xs) (map (f . snd) xs)
@@ -407,32 +436,32 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.Metavariables cols) =
407436 let (out, spans) = render ist bnd t pt in
408437 (show n , out, spans)
409438
410−runIdeSlaveCommand id orig fn mods (IdeSlave.WhoCalls n) =
439+runIdeSlaveCommand h id orig fn mods (IdeSlave.WhoCalls n) =
411440 case splitName n of
412441 Left err -> iPrintError err
413442 Right n -> do calls <- whoCalls n
414443 ist <- getIState
415444 let msg = (IdeSlave.SymbolAtom "ok",
416445 map (\ (n,ns) -> (pn ist n, map (pn ist) ns)) calls)
417− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
446+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
418447 where pn ist = displaySpans .
419448 renderPretty 0.9 1000 .
420449 fmap (fancifyAnnots ist) .
421450 prettyName True True []
422−runIdeSlaveCommand id orig fn mods (IdeSlave.CallsWho n) =
451+runIdeSlaveCommand h id orig fn mods (IdeSlave.CallsWho n) =
423452 case splitName n of
424453 Left err -> iPrintError err
425454 Right n -> do calls <- callsWho n
426455 ist <- getIState
427456 let msg = (IdeSlave.SymbolAtom "ok",
428457 map (\ (n,ns) -> (pn ist n, map (pn ist) ns)) calls)
429− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
458+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
430459 where pn ist = displaySpans .
431460 renderPretty 0.9 1000 .
432461 fmap (fancifyAnnots ist) .
433462 prettyName True True []
434463
435−runIdeSlaveCommand id orig fn modes (IdeSlave.TermNormalise bnd tm) =
464+runIdeSlaveCommand h id orig fn modes (IdeSlave.TermNormalise bnd tm) =
436465 do ctxt <- getContext
437466 ist <- getIState
438467 let tm' = force (normaliseAll ctxt [] tm)
@@ -446,15 +475,15 @@ runIdeSlaveCommand id orig fn modes (IdeSlave.TermNormalise bnd tm) =
446475 displaySpans .
447476 renderPretty 0.9 80 .
448477 fmap (fancifyAnnots ist) $ ptm)
449− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
450−runIdeSlaveCommand id orig fn modes (IdeSlave.TermShowImplicits bnd tm) =
451− ideSlaveForceTermImplicits id bnd True tm
452−runIdeSlaveCommand id orig fn modes (IdeSlave.TermNoImplicits bnd tm) =
453− ideSlaveForceTermImplicits id bnd False tm
478+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
479+runIdeSlaveCommand h id orig fn modes (IdeSlave.TermShowImplicits bnd tm) =
480+ ideSlaveForceTermImplicits h id bnd True tm
481+runIdeSlaveCommand h id orig fn modes (IdeSlave.TermNoImplicits bnd tm) =
482+ ideSlaveForceTermImplicits h id bnd False tm
454483
455484-- | Show a term for IDESlave with the specified implicitness
456−ideSlaveForceTermImplicits :: Integer -> [(Name, Bool)] -> Bool -> Term -> Idris ()
457−ideSlaveForceTermImplicits id bnd impl tm =
485+ideSlaveForceTermImplicits :: Handle -> Integer -> [(Name, Bool)] -> Bool -> Term -> Idris ()
486+ideSlaveForceTermImplicits h id bnd impl tm =
458487 do ist <- getIState
459488 let expl = annotate (AnnTerm bnd tm)
460489 (pprintPTerm ((ppOptionIst ist) { ppopt_impl = impl })
@@ -464,7 +493,7 @@ ideSlaveForceTermImplicits id bnd impl tm =
464493 displaySpans .
465494 renderPretty 0.9 80 .
466495 fmap (fancifyAnnots ist) $ expl)
467− runIO . putStrLn $ IdeSlave.convSExp "return" msg id
496+ runIO . hPutStrLn h $ IdeSlave.convSExp "return" msg id
468497
469498splitName :: String -> Either String Name
470499splitName s = case reverse $ splitOn "." s of
@@ -473,70 +502,70 @@ splitName s = case reverse $ splitOn "." s of
473502 (n:ns) -> Right $ sNS (sUN n) ns
474503
475504ideslaveProcess :: FilePath -> Command -> Idris ()
476−ideslaveProcess fn Warranty = process stdout fn Warranty
477−ideslaveProcess fn Help = process stdout fn Help
478−ideslaveProcess fn (ChangeDirectory f) = do process stdout fn (ChangeDirectory f)
505+ideslaveProcess fn Warranty = process fn Warranty
506+ideslaveProcess fn Help = process fn Help
507+ideslaveProcess fn (ChangeDirectory f) = do process fn (ChangeDirectory f)
479508 iPrintResult "changed directory to"
480−ideslaveProcess fn (Eval t) = process stdout fn (Eval t)
481−ideslaveProcess fn (NewDefn decls) = do process stdout fn (NewDefn decls)
509+ideslaveProcess fn (Eval t) = process fn (Eval t)
510+ideslaveProcess fn (NewDefn decls) = do process fn (NewDefn decls)
482511 iPrintResult "defined"
483−ideslaveProcess fn (ExecVal t) = process stdout fn (ExecVal t)
484−ideslaveProcess fn (Check (PRef x n)) = process stdout fn (Check (PRef x n))
485−ideslaveProcess fn (Check t) = process stdout fn (Check t)
486−ideslaveProcess fn (DocStr n) = process stdout fn (DocStr n)
487−ideslaveProcess fn Universes = process stdout fn Universes
488−ideslaveProcess fn (Defn n) = do process stdout fn (Defn n)
512+ideslaveProcess fn (ExecVal t) = process fn (ExecVal t)
513+ideslaveProcess fn (Check (PRef x n)) = process fn (Check (PRef x n))
514+ideslaveProcess fn (Check t) = process fn (Check t)
515+ideslaveProcess fn (DocStr n) = process fn (DocStr n)
516+ideslaveProcess fn Universes = process fn Universes
517+ideslaveProcess fn (Defn n) = do process fn (Defn n)
489518 iPrintResult ""
490−ideslaveProcess fn (TotCheck n) = process stdout fn (TotCheck n)
491−ideslaveProcess fn (DebugInfo n) = do process stdout fn (DebugInfo n)
519+ideslaveProcess fn (TotCheck n) = process fn (TotCheck n)
520+ideslaveProcess fn (DebugInfo n) = do process fn (DebugInfo n)
492521 iPrintResult ""
493−ideslaveProcess fn (Search t) = process stdout fn (Search t)
494−ideslaveProcess fn (Spec t) = process stdout fn (Spec t)
522+ideslaveProcess fn (Search t) = process fn (Search t)
523+ideslaveProcess fn (Spec t) = process fn (Spec t)
495524-- RmProof and AddProof not supported!
496−ideslaveProcess fn (ShowProof n') = process stdout fn (ShowProof n')
497−ideslaveProcess fn (HNF t) = process stdout fn (HNF t)
498−--ideslaveProcess fn TTShell = process stdout fn TTShell -- need some prove mode!
499−ideslaveProcess fn (TestInline t) = process stdout fn (TestInline t)
525+ideslaveProcess fn (ShowProof n') = process fn (ShowProof n')
526+ideslaveProcess fn (HNF t) = process fn (HNF t)
527+--ideslaveProcess fn TTShell = process fn TTShell -- need some prove mode!
528+ideslaveProcess fn (TestInline t) = process fn (TestInline t)
500529
501−ideslaveProcess fn Execute = do process stdout fn Execute
530+ideslaveProcess fn Execute = do process fn Execute
502531 iPrintResult ""
503−ideslaveProcess fn (Compile codegen f) = do process stdout fn (Compile codegen f)
532+ideslaveProcess fn (Compile codegen f) = do process fn (Compile codegen f)
504533 iPrintResult ""
505−ideslaveProcess fn (LogLvl i) = do process stdout fn (LogLvl i)
534+ideslaveProcess fn (LogLvl i) = do process fn (LogLvl i)
506535 iPrintResult ""
507−ideslaveProcess fn (Pattelab t) = process stdout fn (Pattelab t)
508−ideslaveProcess fn (Missing n) = process stdout fn (Missing n)
509−ideslaveProcess fn (DynamicLink l) = do process stdout fn (DynamicLink l)
536+ideslaveProcess fn (Pattelab t) = process fn (Pattelab t)
537+ideslaveProcess fn (Missing n) = process fn (Missing n)
538+ideslaveProcess fn (DynamicLink l) = do process fn (DynamicLink l)
510539 iPrintResult ""
511−ideslaveProcess fn ListDynamic = do process stdout fn ListDynamic
540+ideslaveProcess fn ListDynamic = do process fn ListDynamic
512541 iPrintResult ""
513−ideslaveProcess fn Metavars = process stdout fn Metavars
514−ideslaveProcess fn (SetOpt ErrContext) = do process stdout fn (SetOpt ErrContext)
542+ideslaveProcess fn Metavars = process fn Metavars
543+ideslaveProcess fn (SetOpt ErrContext) = do process fn (SetOpt ErrContext)
515544 iPrintResult ""
516−ideslaveProcess fn (UnsetOpt ErrContext) = do process stdout fn (UnsetOpt ErrContext)
545+ideslaveProcess fn (UnsetOpt ErrContext) = do process fn (UnsetOpt ErrContext)
517546 iPrintResult ""
518−ideslaveProcess fn (SetOpt ShowImpl) = do process stdout fn (SetOpt ShowImpl)
547+ideslaveProcess fn (SetOpt ShowImpl) = do process fn (SetOpt ShowImpl)
519548 iPrintResult ""
520−ideslaveProcess fn (UnsetOpt ShowImpl) = do process stdout fn (UnsetOpt ShowImpl)
549+ideslaveProcess fn (UnsetOpt ShowImpl) = do process fn (UnsetOpt ShowImpl)
521550 iPrintResult ""
522−ideslaveProcess fn (SetOpt ShowOrigErr) = do process stdout fn (SetOpt ShowOrigErr)
551+ideslaveProcess fn (SetOpt ShowOrigErr) = do process fn (SetOpt ShowOrigErr)
523552 iPrintResult ""
524−ideslaveProcess fn (UnsetOpt ShowOrigErr) = do process stdout fn (UnsetOpt ShowOrigErr)
553+ideslaveProcess fn (UnsetOpt ShowOrigErr) = do process fn (UnsetOpt ShowOrigErr)
525554 iPrintResult ""
526−ideslaveProcess fn (SetOpt x) = process stdout fn (SetOpt x)
527−ideslaveProcess fn (UnsetOpt x) = process stdout fn (UnsetOpt x)
528−ideslaveProcess fn (CaseSplitAt False pos str) = process stdout fn (CaseSplitAt False pos str)
529−ideslaveProcess fn (AddProofClauseFrom False pos str) = process stdout fn (AddProofClauseFrom False pos str)
530−ideslaveProcess fn (AddClauseFrom False pos str) = process stdout fn (AddClauseFrom False pos str)
531−ideslaveProcess fn (AddMissing False pos str) = process stdout fn (AddMissing False pos str)
532−ideslaveProcess fn (MakeWith False pos str) = process stdout fn (MakeWith False pos str)
533−ideslaveProcess fn (DoProofSearch False r pos str xs) = process stdout fn (DoProofSearch False r pos str xs)
534−ideslaveProcess fn (SetConsoleWidth w) = do process stdout fn (SetConsoleWidth w)
555+ideslaveProcess fn (SetOpt x) = process fn (SetOpt x)
556+ideslaveProcess fn (UnsetOpt x) = process fn (UnsetOpt x)
557+ideslaveProcess fn (CaseSplitAt False pos str) = process fn (CaseSplitAt False pos str)
558+ideslaveProcess fn (AddProofClauseFrom False pos str) = process fn (AddProofClauseFrom False pos str)
559+ideslaveProcess fn (AddClauseFrom False pos str) = process fn (AddClauseFrom False pos str)
560+ideslaveProcess fn (AddMissing False pos str) = process fn (AddMissing False pos str)
561+ideslaveProcess fn (MakeWith False pos str) = process fn (MakeWith False pos str)
562+ideslaveProcess fn (DoProofSearch False r pos str xs) = process fn (DoProofSearch False r pos str xs)
563+ideslaveProcess fn (SetConsoleWidth w) = do process fn (SetConsoleWidth w)
535564 iPrintResult ""
536−ideslaveProcess fn (Apropos a) = do process stdout fn (Apropos a)
565+ideslaveProcess fn (Apropos a) = do process fn (Apropos a)
537566 iPrintResult ""
538−ideslaveProcess fn (WhoCalls n) = process stdout fn (WhoCalls n)
539−ideslaveProcess fn (CallsWho n) = process stdout fn (CallsWho n)
567+ideslaveProcess fn (WhoCalls n) = process fn (WhoCalls n)
568+ideslaveProcess fn (CallsWho n) = process fn (CallsWho n)
540569ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
541570
542571
@@ -568,18 +597,18 @@ processInput cmd orig inputs
568597 , idris_colourTheme = idris_colourTheme i
569598 }
570599 clearErr
571− mods <- loadInputs stdout inputs Nothing
600+ mods <- loadInputs inputs Nothing
572601 return (Just inputs)
573602 Success (Load f toline) ->
574603 do putIState orig { idris_options = idris_options i
575604 , idris_colourTheme = idris_colourTheme i
576605 }
577606 clearErr
578− mod <- loadInputs stdout [f] toline
607+ mod <- loadInputs [f] toline
579608 return (Just [f])
580609 Success (ModImport f) ->
581610 do clearErr
582− fmod <- loadModule stdout f
611+ fmod <- loadModule f
583612 return (Just (inputs ++ [fmod]))
584613 Success Edit -> do -- takeMVar stvar
585614 edit fn orig
@@ -588,7 +617,7 @@ processInput cmd orig inputs
588617 return (Just inputs)
589618 Success Quit -> do when (not quiet) (iputStrLn "Bye bye")
590619 return Nothing
591− Success cmd -> do idrisCatch (process stdout fn cmd)
620+ Success cmd -> do idrisCatch (process fn cmd)
592621 (\e -> do msg <- showErr e ; iputStrLn msg)
593622 return (Just inputs)
594623
@@ -624,7 +653,7 @@ edit f orig
624653 putIState $ orig { idris_options = idris_options i
625654 , idris_colourTheme = idris_colourTheme i
626655 }
627− loadInputs stdout [f] Nothing
656+ loadInputs [f] Nothing
628657-- clearOrigPats
629658 iucheck
630659 return ()
@@ -650,13 +679,13 @@ insertScript prf (p@"---------- Proofs ----------" : "" : xs)
650679 = p : "" : prf : xs
651680insertScript prf (x : xs) = x : insertScript prf xs
652681
653−process :: Handle -> FilePath -> Command -> Idris ()
654−process h fn Help = iPrintResult displayHelp
655−process h fn Warranty = iPrintResult warranty
656−process h fn (ChangeDirectory f)
682+process :: FilePath -> Command -> Idris ()
683+process fn Help = iPrintResult displayHelp
684+process fn Warranty = iPrintResult warranty
685+process fn (ChangeDirectory f)
657686 = do runIO $ setCurrentDirectory f
658687 return ()
659−process h fn (Eval t)
688+process fn (Eval t)
660689 = withErrorReflection $ do logLvl 5 $ show t
661690 (tm, ty) <- elabVal recinfo ERHS t
662691 ctxt <- getContext
@@ -669,10 +698,10 @@ process h fn (Eval t)
669698 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
670699 let tmDoc = pprintDelab ist tm'
671700 tyDoc = pprintDelab ist ty'
672− ihPrintTermWithType h tmDoc tyDoc
701+ iPrintTermWithType tmDoc tyDoc
673702
674703
675−process h fn (NewDefn decls) = logLvl 3 ("Defining names using these decls: " ++ show namedGroups) >> mapM_ defineName namedGroups where
704+process fn (NewDefn decls) = logLvl 3 ("Defining names using these decls: " ++ show namedGroups) >> mapM_ defineName namedGroups where
676705 namedGroups = groupBy (\d1 d2 -> getName d1 == getName d2) decls
677706 getName :: PDecl -> Maybe Name
678707 getName (PTy docs argdocs syn fc opts name ty) = Just name
@@ -703,7 +732,7 @@ process h fn (NewDefn decls) = logLvl 3 ("Defining names using these decls: " ++
703732 getRHS (PClauseR fc with rhs whereBlock) = rhs
704733 getRHS (PWithR fc with rhs whereBlock) = rhs
705734
706−process h fn (ExecVal t)
735+process fn (ExecVal t)
707736 = do ctxt <- getContext
708737 ist <- getIState
709738 (tm, ty) <- elabVal recinfo ERHS t
@@ -712,19 +741,19 @@ process h fn (ExecVal t)
712741 res <- execute tm
713742 let (resOut, tyOut) = (prettyIst ist (delab ist res),
714743 prettyIst ist (delab ist ty'))
715− ihPrintTermWithType h resOut tyOut
744+ iPrintTermWithType resOut tyOut
716745
717−process h fn (Check (PRef _ n))
746+process fn (Check (PRef _ n))
718747 = do ctxt <- getContext
719748 ist <- getIState
720749 let ppo = ppOptionIst ist
721750 case lookupNames n ctxt of
722751 ts@(t:_) ->
723752 case lookup t (idris_metavars ist) of
724− Just (_, i, _) -> ihRenderResult h . fmap (fancifyAnnots ist) $
753+ Just (_, i, _) -> iRenderResult . fmap (fancifyAnnots ist) $
725754 showMetavarInfo ppo ist n i
726− Nothing -> ihPrintFunTypes h [] n (map (\n -> (n, delabTy ist n)) ts)
727− [] -> ihPrintError h $ "No such variable " ++ show n
755+ Nothing -> iPrintFunTypes [] n (map (\n -> (n, delabTy ist n)) ts)
756+ [] -> iPrintError $ "No such variable " ++ show n
728757 where
729758 showMetavarInfo ppo ist n i
730759 = case lookupTy n (tt_ctxt ist) of
@@ -749,7 +778,7 @@ process h fn (Check (PRef _ n))
749778 tPretty bnd ist t = pprintPTerm (ppOptionIst ist) bnd [] (idris_infixes ist) t
750779
751780
752−process h fn (Check t)
781+process fn (Check t)
753782 = do (tm, ty) <- elabVal recinfo ERHS t
754783 ctxt <- getContext
755784 ist <- getIState
@@ -757,24 +786,24 @@ process h fn (Check t)
757786 ty' = normaliseC ctxt [] ty
758787 case tm of
759788 TType _ ->
760− ihPrintTermWithType h (prettyIst ist PType) type1Doc
761− _ -> ihPrintTermWithType h (pprintDelab ist tm)
762− (pprintDelab ist ty)
789+ iPrintTermWithType (prettyIst ist PType) type1Doc
790+ _ -> iPrintTermWithType (pprintDelab ist tm)
791+ (pprintDelab ist ty)
763792
764−process h fn (DocStr (Left n))
793+process fn (DocStr (Left n))
765794 = do ist <- getIState
766795 case lookupCtxtName n (idris_docstrings ist) of
767796 [] -> iPrintError $ "No documentation for " ++ show n
768797 ns -> do toShow <- mapM (showDoc ist) ns
769− ihRenderResult h (vsep toShow)
798+ iRenderResult (vsep toShow)
770799 where showDoc ist (n, d) = do doc <- getDocs n
771800 return $ pprintDocs ist doc
772801
773−process h fn (DocStr (Right c))
802+process fn (DocStr (Right c))
774803 = do ist <- getIState
775− ihRenderResult h $ pprintConstDocs ist c (constDocs c)
804+ iRenderResult $ pprintConstDocs ist c (constDocs c)
776805
777−process h fn Universes
806+process fn Universes
778807 = do i <- getIState
779808 let cs = idris_constraints i
780809-- iputStrLn $ showSep "\n" (map show cs)
@@ -784,7 +813,7 @@ process h fn Universes
784813 case ucheck cs of
785814 Error e -> iPrintError $ pshow i e
786815 OK _ -> iPrintResult "Universes OK"
787−process h fn (Defn n)
816+process fn (Defn n)
788817 = do i <- getIState
789818 iputStrLn "Compiled patterns:\n"
790819 iputStrLn $ show (lookupDef n (tt_ctxt i))
@@ -799,20 +828,20 @@ process h fn (Defn n)
799828 = let i' = i { idris_options = (idris_options i) { opt_showimp = True } }
800829 in iputStrLn (showTm i' (delab i lhs) ++ " = " ++
801830 showTm i' (delab i rhs))
802−process h fn (TotCheck n)
831+process fn (TotCheck n)
803832 = do i <- getIState
804833 case lookupNameTotal n (tt_ctxt i) of
805− [] -> ihPrintError h $ "Unknown operator " ++ show n
834+ [] -> iPrintError $ "Unknown operator " ++ show n
806835 ts -> do ist <- getIState
807836 c <- colourise
808837 let ppo = ppOptionIst ist
809838 let showN = showName (Just ist) [] ppo c
810− ihPrintResult h . concat . intersperse "\n" .
839+ iPrintResult . concat . intersperse "\n" .
811840 map (\(n, t) -> showN n ++ " is " ++ showTotal t i) $
812841 ts
813842
814843
815−process h fn (DebugInfo n)
844+process fn (DebugInfo n)
816845 = do i <- getIState
817846 let oi = lookupCtxtName n (idris_optimisation i)
818847 when (not (null oi)) $ iputStrLn (show oi)
@@ -829,29 +858,29 @@ process h fn (DebugInfo n)
829858 iputStrLn $ "Size change: " ++ show sc
830859 when (not (null cg')) $ do iputStrLn "Call graph:\n"
831860 iputStrLn (show cg')
832−process h fn (Search t) = searchByType h t
833−process h fn (CaseSplitAt updatefile l n)
834− = caseSplitAt h fn updatefile l n
835−process h fn (AddClauseFrom updatefile l n)
836− = addClauseFrom h fn updatefile l n
837−process h fn (AddProofClauseFrom updatefile l n)
838− = addProofClauseFrom h fn updatefile l n
839−process h fn (AddMissing updatefile l n)
840− = addMissing h fn updatefile l n
841−process h fn (MakeWith updatefile l n)
842− = makeWith h fn updatefile l n
843−process h fn (MakeLemma updatefile l n)
844− = makeLemma h fn updatefile l n
845−process h fn (DoProofSearch updatefile rec l n hints)
846− = doProofSearch h fn updatefile rec l n hints Nothing
847−process h fn (Spec t)
861+process fn (Search t) = searchByType t
862+process fn (CaseSplitAt updatefile l n)
863+ = caseSplitAt fn updatefile l n
864+process fn (AddClauseFrom updatefile l n)
865+ = addClauseFrom fn updatefile l n
866+process fn (AddProofClauseFrom updatefile l n)
867+ = addProofClauseFrom fn updatefile l n
868+process fn (AddMissing updatefile l n)
869+ = addMissing fn updatefile l n
870+process fn (MakeWith updatefile l n)
871+ = makeWith fn updatefile l n
872+process fn (MakeLemma updatefile l n)
873+ = makeLemma fn updatefile l n
874+process fn (DoProofSearch updatefile rec l n hints)
875+ = doProofSearch fn updatefile rec l n hints Nothing
876+process fn (Spec t)
848877 = do (tm, ty) <- elabVal recinfo ERHS t
849878 ctxt <- getContext
850879 ist <- getIState
851880 let tm' = simplify ctxt [] {- (idris_statics ist) -} tm
852881 iPrintResult (show (delab ist tm'))
853882
854−process h fn (RmProof n')
883+process fn (RmProof n')
855884 = do i <- getIState
856885 n <- resolveProof n'
857886 let proofs = proof_list i
@@ -867,7 +896,7 @@ process h fn (RmProof n')
867896 let ms = idris_metavars i
868897 putIState $ i { idris_metavars = (n, (Nothing, 0, False)) : ms }
869898
870−process h fn' (AddProof prf)
899+process fn' (AddProof prf)
871900 = do fn <- do
872901 let fn'' = takeWhile (/= ' ') fn'
873902 ex <- runIO $ doesFileExist fn''
@@ -897,7 +926,7 @@ process h fn' (AddProof prf)
897926 iputStrLn $ "Added proof " ++ show n
898927 where ls = (lines prog)
899928
900−process h fn (ShowProof n')
929+process fn (ShowProof n')
901930 = do i <- getIState
902931 n <- resolveProof n'
903932 let proofs = proof_list i
@@ -905,7 +934,7 @@ process h fn (ShowProof n')
905934 Nothing -> iPrintError "No proof to show"
906935 Just p -> iPrintResult $ showProof False n p
907936
908−process h fn (Prove n')
937+process fn (Prove n')
909938 = do ctxt <- getContext
910939 ist <- getIState
911940 let ns = lookupNames n' ctxt
@@ -923,20 +952,20 @@ process h fn (Prove n')
923952 mapM_ checkDeclTotality (idris_totcheck i)
924953 warnTotality
925954
926−process h fn (HNF t)
955+process fn (HNF t)
927956 = do (tm, ty) <- elabVal recinfo ERHS t
928957 ctxt <- getContext
929958 ist <- getIState
930959 let tm' = hnf ctxt [] tm
931960 iPrintResult (show (delab ist tm'))
932−process h fn (TestInline t)
961+process fn (TestInline t)
933962 = do (tm, ty) <- elabVal recinfo ERHS t
934963 ctxt <- getContext
935964 ist <- getIState
936965 let tm' = inlineTerm ist tm
937966 c <- colourise
938967 iPrintResult (showTm ist (delab ist tm'))
939−process h fn Execute
968+process fn Execute
940969 = idrisCatch
941970 (do ist <- getIState
942971 (m, _) <- elabVal recinfo ERHS
@@ -948,33 +977,33 @@ process h fn Execute
948977 t <- codegen
949978 compile t tmpn m
950979 case idris_outputmode ist of
951− RawOutput -> do runIO $ system tmpn
952− return ()
953− IdeSlave n -> runIO . hPutStrLn h $
954− IdeSlave.convSExp "run-program" tmpn n)
955− (\e -> getIState >>= ihRenderError stdout . flip pprintErr e)
980+ RawOutput h -> do runIO $ system tmpn
981+ return ()
982+ IdeSlave n h -> runIO . hPutStrLn h $
983+ IdeSlave.convSExp "run-program" tmpn n)
984+ (\e -> getIState >>= iRenderError . flip pprintErr e)
956985 where fc = fileFC "main"
957−process h fn (Compile codegen f)
986+process fn (Compile codegen f)
958987 = do (m, _) <- elabVal recinfo ERHS
959988 (PApp fc (PRef fc (sUN "run__IO"))
960989 [pexp $ PRef fc (sNS (sUN "main") ["Main"])])
961990 compile codegen f m
962991 where fc = fileFC "main"
963−process h fn (LogLvl i) = setLogLevel i
992+process fn (LogLvl i) = setLogLevel i
964993-- Elaborate as if LHS of a pattern (debug command)
965−process h fn (Pattelab t)
994+process fn (Pattelab t)
966995 = do (tm, ty) <- elabVal recinfo ELHS t
967996 iPrintResult $ show tm ++ "\n\n : " ++ show ty
968997
969−process h fn (Missing n)
998+process fn (Missing n)
970999 = do i <- getIState
9711000 let i' = i { idris_options = (idris_options i) { opt_showimp = True } }
9721001 case lookupCtxt n (idris_patdefs i) of
973− [] -> ihPrintError h $ "Unknown operator " ++ show n
1002+ [] -> iPrintError $ "Unknown operator " ++ show n
9741003 [(_, tms)] ->
9751004 iPrintResult (showSep "\n" (map (showTm i') tms))
9761005 _ -> iPrintError $ "Ambiguous name"
977−process h fn (DynamicLink l)
1006+process fn (DynamicLink l)
9781007 = do i <- getIState
9791008 let importdirs = opt_importdirs (idris_options i)
9801009 lib = trim l
@@ -987,80 +1016,80 @@ process h fn (DynamicLink l)
9871016 return ()
9881017 else putIState $ i { idris_dynamic_libs = x:libs }
9891018 where trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace
990−process h fn ListDynamic
1019+process fn ListDynamic
9911020 = do i <- getIState
9921021 iputStrLn "Dynamic libraries:"
9931022 showLibs $ idris_dynamic_libs i
9941023 where showLibs [] = return ()
9951024 showLibs ((Lib name _):ls) = do iputStrLn $ "\t" ++ name; showLibs ls
996−process h fn Metavars
1025+process fn Metavars
9971026 = do ist <- getIState
9981027 let mvs = map fst (idris_metavars ist) \\ primDefs
9991028 case mvs of
10001029 [] -> iPrintError "No global metavariables to solve"
10011030 _ -> iPrintResult $ "Global metavariables:\n\t" ++ show mvs
1002−process h fn NOP = return ()
1003−
1004−process h fn (SetOpt ErrContext) = setErrContext True
1005−process h fn (UnsetOpt ErrContext) = setErrContext False
1006−process h fn (SetOpt ShowImpl) = setImpShow True
1007−process h fn (UnsetOpt ShowImpl) = setImpShow False
1008−process h fn (SetOpt ShowOrigErr) = setShowOrigErr True
1009−process h fn (UnsetOpt ShowOrigErr) = setShowOrigErr False
1010−process h fn (SetOpt AutoSolve) = setAutoSolve True
1011−process h fn (UnsetOpt AutoSolve) = setAutoSolve False
1012−process h fn (SetOpt NoBanner) = setNoBanner True
1013−process h fn (UnsetOpt NoBanner) = setNoBanner False
1014−process h fn (SetOpt WarnReach) = fmodifyState opts_idrisCmdline $ nub . (WarnReach:)
1015−process h fn (UnsetOpt WarnReach) = fmodifyState opts_idrisCmdline $ delete WarnReach
1016−
1017−process h fn (SetOpt _) = iPrintError "Not a valid option"
1018−process h fn (UnsetOpt _) = iPrintError "Not a valid option"
1019−process h fn (SetColour ty c) = setColour ty c
1020−process h fn ColourOn
1031+process fn NOP = return ()
1032+
1033+process fn (SetOpt ErrContext) = setErrContext True
1034+process fn (UnsetOpt ErrContext) = setErrContext False
1035+process fn (SetOpt ShowImpl) = setImpShow True
1036+process fn (UnsetOpt ShowImpl) = setImpShow False
1037+process fn (SetOpt ShowOrigErr) = setShowOrigErr True
1038+process fn (UnsetOpt ShowOrigErr) = setShowOrigErr False
1039+process fn (SetOpt AutoSolve) = setAutoSolve True
1040+process fn (UnsetOpt AutoSolve) = setAutoSolve False
1041+process fn (SetOpt NoBanner) = setNoBanner True
1042+process fn (UnsetOpt NoBanner) = setNoBanner False
1043+process fn (SetOpt WarnReach) = fmodifyState opts_idrisCmdline $ nub . (WarnReach:)
1044+process fn (UnsetOpt WarnReach) = fmodifyState opts_idrisCmdline $ delete WarnReach
1045+
1046+process fn (SetOpt _) = iPrintError "Not a valid option"
1047+process fn (UnsetOpt _) = iPrintError "Not a valid option"
1048+process fn (SetColour ty c) = setColour ty c
1049+process fn ColourOn
10211050 = do ist <- getIState
10221051 putIState $ ist { idris_colourRepl = True }
1023−process h fn ColourOff
1052+process fn ColourOff
10241053 = do ist <- getIState
10251054 putIState $ ist { idris_colourRepl = False }
1026−process h fn ListErrorHandlers =
1055+process fn ListErrorHandlers =
10271056 do ist <- getIState
10281057 iPrintResult $ case idris_errorhandlers ist of
10291058 [] -> "No registered error handlers"
10301059 handlers -> "Registered error handlers: " ++ (concat . intersperse ", " . map show) handlers
1031−process h fn (SetConsoleWidth w) = setWidth w
1060+process fn (SetConsoleWidth w) = setWidth w
10321061
1033−process h fn (Apropos a) =
1062+process fn (Apropos a) =
10341063 do ist <- getIState
10351064 let names = apropos ist (T.pack a)
10361065 let aproposInfo = [ (n,
10371066 delabTy ist n,
10381067 fmap (overview . fst) (lookupCtxtExact n (idris_docstrings ist)))
10391068 | n <- sort names, isUN n ]
1040− ihRenderResult h $ vsep (map (prettyDocumentedIst ist) aproposInfo)
1069+ iRenderResult $ vsep (map (prettyDocumentedIst ist) aproposInfo)
10411070 where isUN (UN _) = True
10421071 isUN (NS n _) = isUN n
10431072 isUN _ = False
10441073
1045−process h fn (WhoCalls n) =
1074+process fn (WhoCalls n) =
10461075 do calls <- whoCalls n
10471076 ist <- getIState
1048− ihRenderResult h . vsep $
1077+ iRenderResult . vsep $
10491078 map (\(n, ns) ->
10501079 text "Callers of" <+> prettyName True True [] n <$>
10511080 indent 1 (vsep (map ((text "*" <+>) . align . prettyName True True []) ns)))
10521081 calls
10531082
1054−process h fn (CallsWho n) =
1083+process fn (CallsWho n) =
10551084 do calls <- callsWho n
10561085 ist <- getIState
1057− ihRenderResult h . vsep $
1086+ iRenderResult . vsep $
10581087 map (\(n, ns) ->
10591088 prettyName True True [] n <+> text "calls:" <$>
10601089 indent 1 (vsep (map ((text "*" <+>) . align . prettyName True True []) ns)))
10611090 calls
10621091-- IdrisDoc
1063−process h fn (MakeDoc s) =
1092+process fn (MakeDoc s) =
10641093 do istate <- getIState
10651094 let names = words s
10661095 parse n | Success x <- runparser name istate fn n = Right x
@@ -1117,8 +1146,8 @@ idris opts = do res <- runErrorT $ execStateT totalMain idrisInit
11171146 [] -> return ()
11181147
11191148
1120−loadInputs :: Handle -> [FilePath] -> Maybe Int -> Idris ()
1121−loadInputs h inputs toline -- furthest line to read in input source files
1149+loadInputs :: [FilePath] -> Maybe Int -> Idris ()
1150+loadInputs inputs toline -- furthest line to read in input source files
11221151 = idrisCatch
11231152 (do ist <- getIState
11241153 -- if we're in --check and not outputting anything, don't bother
@@ -1170,10 +1199,10 @@ loadInputs h inputs toline -- furthest line to read in input source files
11701199 (\e -> do i <- getIState
11711200 case e of
11721201 At f e' -> do setErrSpan f
1173− ihWarn stdout f $ pprintErr i e'
1202+ iWarn f $ pprintErr i e'
11741203 ProgramLineComment -> return () -- fail elsewhere
11751204 _ -> do setErrSpan emptyFC -- FIXME! Propagate it
1176− ihWarn stdout emptyFC $ pprintErr i e)
1205+ iWarn emptyFC $ pprintErr i e)
11771206 where -- load all files, stop if any fail
11781207 tryLoad :: Bool -> [IFileType] -> Idris ()
11791208 tryLoad keepstate [] = warnTotality >> return ()
@@ -1190,7 +1219,7 @@ loadInputs h inputs toline -- furthest line to read in input source files
11901219 then Just l
11911220 else Nothing
11921221 _ -> Nothing
1193− loadFromIFile h f maxline
1222+ loadFromIFile f maxline
11941223 inew <- getIState
11951224 -- FIXME: Save these in IBC to avoid this hack! Need to
11961225 -- preserve it all from source inputs
@@ -1238,7 +1267,7 @@ idrisMain opts =
12381267 do let inputs = opt getFile opts
12391268 let quiet = Quiet `elem` opts
12401269 let nobanner = NoBanner `elem` opts
1241− let idesl = Ideslave `elem` opts
1270+ let idesl = Ideslave `elem` opts || IdeslaveSocket `elem` opts
12421271 let runrepl = not (NoREPL `elem` opts)
12431272 let verbose = runrepl || Verbose `elem` opts
12441273 let output = opt getOutput opts
@@ -1275,7 +1304,6 @@ idrisMain opts =
12751304 mapM_ addLangExt (opt getLanguageExt opts)
12761305 setREPL runrepl
12771306 setQuiet (quiet || isJust script || not (null immediate))
1278− setIdeSlave idesl
12791307 setVerbose verbose
12801308 setCmdLine opts
12811309 setOutputTy outty
@@ -1301,9 +1329,9 @@ idrisMain opts =
13011329 addPkgDir "base"
13021330 mapM_ addPkgDir pkgdirs
13031331 elabPrims
1304− when (not (NoBuiltins `elem` opts)) $ do x <- loadModule stdout "Builtins"
1332+ when (not (NoBuiltins `elem` opts)) $ do x <- loadModule "Builtins"
13051333 return ()
1306− when (not (NoPrelude `elem` opts)) $ do x <- loadModule stdout "Prelude"
1334+ when (not (NoPrelude `elem` opts)) $ do x <- loadModule "Prelude"
13071335 return ()
13081336
13091337 when (runrepl && not idesl) initScript
@@ -1319,14 +1347,14 @@ idrisMain opts =
13191347 iputStrLn banner
13201348
13211349 orig <- getIState
1322− loadInputs stdout inputs Nothing
1350+ when (not idesl) $ loadInputs inputs Nothing
13231351
13241352 runIO $ hSetBuffering stdout LineBuffering
13251353
13261354 ok <- noErrors
13271355 when ok $ case output of
13281356 [] -> return ()
1329− (o:_) -> idrisCatch (process stdout "" (Compile cgn o))
1357+ (o:_) -> idrisCatch (process "" (Compile cgn o))
13301358 (\e -> do ist <- getIState ; iputStrLn $ pshow ist e)
13311359
13321360 case immediate of
@@ -1337,7 +1365,7 @@ idrisMain opts =
13371365 case parseExpr ist str of
13381366 Failure err -> do iputStrLn $ show (fixColour c err)
13391367 runIO $ exitWith (ExitFailure 1)
1340− Success e -> process stdout "" (Eval e))
1368+ Success e -> process "" (Eval e))
13411369 exprs
13421370 runIO $ exitWith ExitSuccess
13431371
@@ -1359,7 +1387,8 @@ idrisMain opts =
13591387-- clearOrigPats
13601388 startServer orig inputs
13611389 runInputT (replSettings (Just historyFile)) $ repl orig inputs
1362− when (idesl) $ ideslaveStart orig inputs
1390+ let idesock = IdeslaveSocket `elem` opts
1391+ when (idesl) $ ideslaveStart idesock orig inputs
13631392 ok <- noErrors
13641393 when (not ok) $ runIO (exitWith (ExitFailure 1))
13651394 where
@@ -1421,7 +1450,7 @@ initScript = do script <- getInitScript
14211450 Success Edit -> iPrintError "Init scripts cannot invoke the editor"
14221451 Success Proofs -> proofs i
14231452 Success Quit -> iPrintError "Init scripts cannot quit Idris"
1424− Success cmd -> process stdout [] cmd
1453+ Success cmd -> process [] cmd
14251454
14261455getFile :: Opt -> Maybe String
14271456getFile (Filename str) = Just str