on master help sign in
Merge pull request #2355 from david-christiansen/interactive-fix

Interactive fix

commit101f5f935cff60611809047025a4fef89d2e2dee authorDavid Christiansen <david@davidchristiansen.dk> dateMon 8 Jun 2015, 19:20 (11 years ago) parent705c36b34f516d
2 files changed+22−7
src/Idris/AbsSyntax.hs+18−5 src/Idris/REPL.hs+4−2
src/Idris/AbsSyntax.hs+18−5
@@ -16,6 +16,7 @@ import Util.DynamicLinker
1616
1717import System.Console.Haskeline
1818import System.IO
19+import System.Directory (canonicalizePath, doesFileExist)
1920
2021import Control.Applicative
2122import Control.Monad (liftM3)
@@ -516,14 +517,26 @@ getName = do i <- getIState;
516517addInternalApp :: FilePath -> Int -> PTerm -> Idris ()
517518addInternalApp fp l t
518519 = do i <- getIState
519− putIState (i { idris_lineapps = ((fp, l), t) : idris_lineapps i })
520+ -- We canonicalise the path to make "./Test/Module.idr" equal
521+ -- to "Test/Module.idr"
522+ exists <- runIO $ doesFileExist fp
523+ when exists $
524+ do fp' <- runIO $ canonicalizePath fp
525+ putIState (i { idris_lineapps = ((fp', l), t) : idris_lineapps i })
520526
521527getInternalApp :: FilePath -> Int -> Idris PTerm
522528getInternalApp fp l = do i <- getIState
523− case lookup (fp, l) (idris_lineapps i) of
524− Just n' -> return n'
525− Nothing -> return Placeholder
526− -- TODO: What if it's not there?
529+ -- We canonicalise the path to make
530+ -- "./Test/Module.idr" equal to
531+ -- "Test/Module.idr"
532+ exists <- runIO $ doesFileExist fp
533+ if exists
534+ then do fp' <- runIO $ canonicalizePath fp
535+ case lookup (fp', l) (idris_lineapps i) of
536+ Just n' -> return n'
537+ Nothing -> return Placeholder
538+ -- TODO: What if it's not there?
539+ else return Placeholder
527540
528541-- Pattern definitions are only used for coverage checking, so erase them
529542-- when we're done
src/Idris/REPL.hs+4−2
@@ -573,8 +573,10 @@ splitName s = case reverse $ splitOn "." s of
573573idemodeProcess :: FilePath -> Command -> Idris ()
574574idemodeProcess fn Warranty = process fn Warranty
575575idemodeProcess fn Help = process fn Help
576−idemodeProcess fn (ChangeDirectory f) = do process fn (ChangeDirectory f)
577− iPrintResult "changed directory to"
576+idemodeProcess fn (ChangeDirectory f) =
577+ do process fn (ChangeDirectory f)
578+ dir <- runIO $ getCurrentDirectory
579+ iPrintResult $ "changed directory to " ++ dir
578580idemodeProcess fn (ModImport f) = process fn (ModImport f)
579581idemodeProcess fn (Eval t) = process fn (Eval t)
580582idemodeProcess fn (NewDefn decls) = do process fn (NewDefn decls)