@@ -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