@@ -304,8 +304,9 @@ process fn (Eval t)
304304 logLvl 3 $ "Raw: " ++ show (tm', ty')
305305 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
306306 imp <- impShow
307− iResult (showImp (Just ist) imp True (delab ist tm') ++ " : " ++
308− showImp (Just ist) imp True (delab ist ty'))
307+ c <- colourise
308+ iResult (showImp (Just ist) imp c (delab ist tm') ++ " : " ++
309+ showImp (Just ist) imp c (delab ist ty'))
309310process fn (ExecVal t)
310311 = do ctxt <- getContext
311312 ist <- getIState
@@ -314,15 +315,17 @@ process fn (ExecVal t)
314315 let ty' = normaliseAll ctxt [] ty
315316 res <- execute tm
316317 imp <- impShow
317− iResult (showImp (Just ist) imp True (delab ist res) ++ " : " ++
318− showImp (Just ist) imp True (delab ist ty'))
318+ c <- colourise
319+ iResult (showImp (Just ist) imp c (delab ist res) ++ " : " ++
320+ showImp (Just ist) imp c (delab ist ty'))
319321process fn (Check (PRef _ n))
320322 = do ctxt <- getContext
321323 ist <- getIState
322324 imp <- impShow
325+ c <- colourise
323326 case lookupNames n ctxt of
324327 ts@(_:_) -> do mapM_ (\n -> iputStrLn $ show n ++ " : " ++
325− showImp (Just ist) imp True (delabTy ist n)) ts
328+ showImp (Just ist) imp c (delabTy ist n)) ts
326329 iResult ""
327330 [] -> iFail $ "No such variable " ++ show n
328331process fn (Check t)
@@ -330,11 +333,12 @@ process fn (Check t)
330333 ctxt <- getContext
331334 ist <- getIState
332335 imp <- impShow
336+ c <- colourise
333337 let ty' = normaliseC ctxt [] ty
334338 case tm of
335339 TType _ -> iResult ("Type : Type 1")
336− _ -> iResult (showImp (Just ist) imp True (delab ist tm) ++ " : " ++
337− showImp (Just ist) imp True (delab ist ty))
340+ _ -> iResult (showImp (Just ist) imp c (delab ist tm) ++ " : " ++
341+ showImp (Just ist) imp c (delab ist ty))
338342
339343process fn (DocStr n) = do i <- getIState
340344 case lookupCtxtName n (idris_docstrings i) of
@@ -364,8 +368,9 @@ process fn (Defn n) = do i <- getIState
364368 [t] -> iputStrLn (showTotal t i)
365369 _ -> return ()
366370 where printCase i (_, lhs, rhs)
367− = do iputStrLn (showImp (Just i) True False (delab i lhs) ++ " = " ++
368− showImp (Just i) True False (delab i rhs))
371+ = do c <- colourise
372+ iputStrLn (showImp (Just i) True c (delab i lhs) ++ " = " ++
373+ showImp (Just i) True c (delab i rhs))
369374process fn (TotCheck n) = do i <- getIState
370375 case lookupTotal n (tt_ctxt i) of
371376 [t] -> iResult (showTotal t i)
@@ -502,10 +507,11 @@ process fn (Pattelab t)
502507
503508process fn (Missing n)
504509 = do i <- getIState
510+ c <- colourise
505511 case lookupCtxt n (idris_patdefs i) of
506512 [] -> return ()
507513 [(_, tms)] ->
508− iResult (showSep "\n" (map (showImp (Just i) True False) tms))
514+ iResult (showSep "\n" (map (showImp (Just i) True c) tms))
509515 _ -> iFail $ "Ambiguous name"
510516process fn (DynamicLink l) = do i <- getIState
511517 let lib = trim l
@@ -627,6 +633,10 @@ parseArgs ("-O0":ns) = OptLevel 0 : parseArgs ns
627633parseArgs ("-O":n:ns) = OptLevel (read n) : parseArgs ns
628634parseArgs ("--target":n:ns) = TargetTriple n : parseArgs ns
629635parseArgs ("--cpu":n:ns) = TargetCPU n : parseArgs ns
636+parseArgs ("--colour":ns) = ColourREPL True : parseArgs ns
637+parseArgs ("--color":ns) = ColourREPL True : parseArgs ns
638+parseArgs ("--nocolour":ns) = ColourREPL False : parseArgs ns
639+parseArgs ("--nocolor":ns) = ColourREPL False : parseArgs ns
630640parseArgs (n:ns) = Filename n : (parseArgs ns)
631641
632642helphead =
@@ -740,6 +750,10 @@ idrisMain opts =
740750 [expr] -> return (Just expr)
741751 when (DefaultTotal `elem` opts) $ do i <- getIState
742752 putIState (i { default_total = True })
753+ case opt getColour opts of
754+ [] -> return ()
755+ xs -> do i <- getIState
756+ putIState (i { idris_colourRepl = last xs })
743757 mapM_ addLangExt (opt getLanguageExt opts)
744758 setREPL runrepl
745759 setQuiet (quiet || isJust script)
@@ -876,6 +890,10 @@ getOptLevel :: Opt -> Maybe Int
876890getOptLevel (OptLevel x) = Just x
877891getOptLevel _ = Nothing
878892
893+getColour :: Opt -> Maybe Bool
894+getColour (ColourREPL b) = Just b
895+getColour _ = Nothing
896+
879897opt :: (Opt -> Maybe a) -> [Opt] -> [a]
880898opt = mapMaybe
881899