on master help sign in
Merge pull request #3869 from mheinzel/master
2cb780aNiklas Larsson
src/Idris/Interactive.hs+5−7
@@ -111,7 +111,7 @@ addMissing :: FilePath -> Bool -> Int -> Name -> Idris ()
111addMissing fn updatefile l n
111addMissing fn updatefile l n
112 = do src <- runIO $ readSource fn
112 = do src <- runIO $ readSource fn
113 let (before, tyline : later) = splitAt (l-1) (lines src)
113 let (before, tyline : later) = splitAt (l-1) (lines src)
114− let indent = getIndent 0 (show n) tyline
114+ let indent = getIndent tyline
115 i <- getIState
115 i <- getIState
116 cl <- getInternalApp fn l
116 cl <- getInternalApp fn l
117 let n' = getAppName cl
117 let n' = getAppName cl
@@ -124,9 +124,9 @@ addMissing fn updatefile l n
124 if updatefile
124 if updatefile
125 then do let fb = fn ++ "~"
125 then do let fb = fn ++ "~"
126 runIO $ writeSource fb (unlines (before ++ nonblank)
126 runIO $ writeSource fb (unlines (before ++ nonblank)
127− ++ extras ++
127+ ++ extras
128− (if null extras then ""
128+ ++ (if null extras then "" else "\n")
129− else "\n" ++ unlines rest))
129+ ++ unlines rest)
130 runIO $ copyFile fb fn
130 runIO $ copyFile fb fn
131 else iPrintResult extras
131 else iPrintResult extras
132 where showPat = show . stripNS
132 where showPat = show . stripNS
@@ -155,9 +155,7 @@ addMissing fn updatefile l n
155 "\n" ++ rest))
155 "\n" ++ rest))
156 showNew nm i _ [] = return ""
156 showNew nm i _ [] = return ""
157
157
158− getIndent i n [] = 0
158+ getIndent s = length (takeWhile isSpace s)
159− getIndent i n xs | take (length n) xs == n = i
160− getIndent i n (x : xs) = getIndent (i + 1) n xs
161
159
162
160
163makeWith :: FilePath -> Bool -> Int -> Name -> Idris ()
161makeWith :: FilePath -> Bool -> Int -> Name -> Idris ()
test/TestData.hs+3−1
@@ -155,7 +155,9 @@ testFamiliesData = [
155 ( 11, ANY ),
155 ( 11, ANY ),
156 ( 12, ANY ),
156 ( 12, ANY ),
157 ( 13, ANY ),
157 ( 13, ANY ),
158− ( 14, C_CG )]),
158+ ( 14, C_CG ),
159+ ( 15, ANY ),
160+ ( 16, ANY )]),
159 ("interfaces", "Interfaces",
161 ("interfaces", "Interfaces",
160 [ ( 1, ANY ),
162 [ ( 1, ANY ),
161 ( 2, ANY ),
163 ( 2, ANY ),
test/interactive015/expectednew file+6
@@ -0,0 +1,6 @@
1+test (Just x) = ?Nothing_rhs_1
2+
3+test : Maybe a -> Bool
4+test Nothing = False
5+test (Just x) = ?Nothing_rhs_1
6+
test/interactive015/inputnew file+2
@@ -0,0 +1,2 @@
1+:addmissing 3 Nothing
2+:addmissing! 3 Nothing
test/interactive015/runnew file+8
@@ -0,0 +1,8 @@
1+#!/usr/bin/env bash
2+
3+cp src/interactive015.idr .
4+${IDRIS:-idris} "$@" --quiet --port none interactive015.idr < input
5+
6+cat interactive015.idr
7+
8+rm -f *.ibc interactive015.idr
test/interactive015/src/interactive015.idrnew file+4
@@ -0,0 +1,4 @@
1+
2+test : Maybe a -> Bool
3+test Nothing = False
4+
test/interactive016/expectednew file+7
@@ -0,0 +1,7 @@
1+
2+test : Maybe a -> Bool
3+test Nothing = False
4+test (Just x) = True
5+
6+other : Int
7+other = 3
test/interactive016/inputnew file+2
@@ -0,0 +1,2 @@
1+:addmissing 3 Nothing
2+:addmissing! 3 Nothing
test/interactive016/runnew file+8
@@ -0,0 +1,8 @@
1+#!/usr/bin/env bash
2+
3+cp src/interactive016.idr .
4+${IDRIS:-idris} "$@" --quiet --port none interactive016.idr < input
5+
6+cat interactive016.idr
7+
8+rm -f *.ibc interactive016.idr
test/interactive016/src/interactive016.idrnew file+7
@@ -0,0 +1,7 @@
1+
2+test : Maybe a -> Bool
3+test Nothing = False
4+test (Just x) = True
5+
6+other : Int
7+other = 3