@@ -17,7 +17,6 @@ import Idris.Error
1717import Idris.Delaborate
1818import Idris.Output
1919import Idris.IdeMode hiding (IdeModeCommand(..))
20−
2120import Idris.Elab.Value
2221
2322import Util.Pretty
@@ -34,7 +33,7 @@ import Debug.Trace
3433
3534caseSplitAt :: FilePath -> Bool -> Int -> Name -> Idris ()
3635caseSplitAt fn updatefile l n
37− = do src <- runIO $ readFile fn
36+ = do src <- runIO $ readSource fn
3837 res <- splitOnLine l n fn
3938 iLOG (showSep "\n" (map show res))
4039 let (before, (ap : later)) = splitAt (l-1) (lines src)
@@ -42,14 +41,14 @@ caseSplitAt fn updatefile l n
4241 let new = concat res'
4342 if updatefile
4443 then do let fb = fn ++ "~" -- make a backup!
45− runIO $ writeFile fb (unlines before ++ new ++ unlines later)
44+ runIO $ writeSource fb (unlines before ++ new ++ unlines later)
4645 runIO $ copyFile fb fn
4746 else -- do iputStrLn (show res)
4847 iPrintResult new
4948
5049addClauseFrom :: FilePath -> Bool -> Int -> Name -> Idris ()
5150addClauseFrom fn updatefile l n
52− = do src <- runIO $ readFile fn
51+ = do src <- runIO $ readSource fn
5352 let (before, tyline : later) = splitAt (l-1) (lines src)
5453 let indent = getIndent 0 (show n) tyline
5554 cl <- getClause l n fn
@@ -57,7 +56,7 @@ addClauseFrom fn updatefile l n
5756 let (nonblank, rest) = span (not . all isSpace) (tyline:later)
5857 if updatefile
5958 then do let fb = fn ++ "~"
60− runIO $ writeFile fb (unlines (before ++ nonblank) ++
59+ runIO $ writeSource fb (unlines (before ++ nonblank) ++
6160 replicate indent ' ' ++
6261 cl ++ "\n" ++
6362 unlines rest)
@@ -71,7 +70,7 @@ addClauseFrom fn updatefile l n
7170
7271addProofClauseFrom :: FilePath -> Bool -> Int -> Name -> Idris ()
7372addProofClauseFrom fn updatefile l n
74− = do src <- runIO $ readFile fn
73+ = do src <- runIO $ readSource fn
7574 let (before, tyline : later) = splitAt (l-1) (lines src)
7675 let indent = getIndent 0 (show n) tyline
7776 cl <- getProofClause l n fn
@@ -79,7 +78,7 @@ addProofClauseFrom fn updatefile l n
7978 let (nonblank, rest) = span (not . all isSpace) (tyline:later)
8079 if updatefile
8180 then do let fb = fn ++ "~"
82− runIO $ writeFile fb (unlines (before ++ nonblank) ++
81+ runIO $ writeSource fb (unlines (before ++ nonblank) ++
8382 replicate indent ' ' ++
8483 cl ++ "\n" ++
8584 unlines rest)
@@ -92,7 +91,7 @@ addProofClauseFrom fn updatefile l n
9291
9392addMissing :: FilePath -> Bool -> Int -> Name -> Idris ()
9493addMissing fn updatefile l n
95− = do src <- runIO $ readFile fn
94+ = do src <- runIO $ readSource fn
9695 let (before, tyline : later) = splitAt (l-1) (lines src)
9796 let indent = getIndent 0 (show n) tyline
9897 i <- getIState
@@ -106,7 +105,7 @@ addMissing fn updatefile l n
106105 let (nonblank, rest) = span (not . all isSpace) (tyline:later)
107106 if updatefile
108107 then do let fb = fn ++ "~"
109− runIO $ writeFile fb (unlines (before ++ nonblank)
108+ runIO $ writeSource fb (unlines (before ++ nonblank)
110109 ++ extras ++ unlines rest)
111110 runIO $ copyFile fb fn
112111 else iPrintResult extras
@@ -141,7 +140,7 @@ addMissing fn updatefile l n
141140
142141makeWith :: FilePath -> Bool -> Int -> Name -> Idris ()
143142makeWith fn updatefile l n
144− = do src <- runIO $ readFile fn
143+ = do src <- runIO $ readSource fn
145144 let (before, tyline : later) = splitAt (l-1) (lines src)
146145 let ind = getIndent tyline
147146 let with = mkWith tyline n
@@ -151,7 +150,7 @@ makeWith fn updatefile l n
151150 not (ind == getIndent x)) later
152151 if updatefile then
153152 do let fb = fn ++ "~"
154− runIO $ writeFile fb (unlines (before ++ nonblank)
153+ runIO $ writeSource fb (unlines (before ++ nonblank)
155154 ++ with ++ "\n" ++
156155 unlines rest)
157156 runIO $ copyFile fb fn
@@ -164,7 +163,7 @@ doProofSearch :: FilePath -> Bool -> Bool ->
164163doProofSearch fn updatefile rec l n hints Nothing
165164 = doProofSearch fn updatefile rec l n hints (Just 10)
166165doProofSearch fn updatefile rec l n hints (Just depth)
167− = do src <- runIO $ readFile fn
166+ = do src <- runIO $ readSource fn
168167 let (before, tyline : later) = splitAt (l-1) (lines src)
169168 ctxt <- getContext
170169 mn <- case lookupNames n ctxt of
@@ -192,7 +191,7 @@ doProofSearch fn updatefile rec l n hints (Just depth)
192191 (\e -> return ("?" ++ show n))
193192 if updatefile then
194193 do let fb = fn ++ "~"
195− runIO $ writeFile fb (unlines before ++
194+ runIO $ writeSource fb (unlines before ++
196195 updateMeta False tyline (show n) newmv ++ "\n"
197196 ++ unlines later)
198197 runIO $ copyFile fb fn
@@ -241,7 +240,7 @@ addBracket True new | any isSpace new = '(' : new ++ ")"
241240
242241makeLemma :: FilePath -> Bool -> Int -> Name -> Idris ()
243242makeLemma fn updatefile l n
244− = do src <- runIO $ readFile fn
243+ = do src <- runIO $ readSource fn
245244 let (before, tyline : later) = splitAt (l-1) (lines src)
246245
247246 -- if the name is in braces, rather than preceded by a ?, treat it
@@ -267,7 +266,7 @@ makeLemma fn updatefile l n
267266
268267 if updatefile then
269268 do let fb = fn ++ "~"
270− runIO $ writeFile fb (addLem before tyline lem lem_app later)
269+ runIO $ writeSource fb (addLem before tyline lem lem_app later)
271270 runIO $ copyFile fb fn
272271 else case idris_outputmode i of
273272 RawOutput _ -> iPrintResult $ lem ++ "\n" ++ lem_app
@@ -285,7 +284,7 @@ makeLemma fn updatefile l n
285284 " = ?" ++ show n ++ "_rhs"
286285 if updatefile then
287286 do let fb = fn ++ "~"
288− runIO $ writeFile fb (addProv before tyline lem_app later)
287+ runIO $ writeSource fb (addProv before tyline lem_app later)
289288 runIO $ copyFile fb fn
290289 else case idris_outputmode i of
291290 RawOutput _ -> iPrintResult $ lem_app