@@ -114,12 +114,12 @@ addLangExt ErrorReflection = do i <- getIState
114114-- Transforms are organised by the function being applied on the lhs of the
115115-- transform, to make looking up appropriate transforms quicker
116116addTrans :: Name -> (Term, Term) -> Idris ()
117−addTrans basefn t
117+addTrans basefn t
118118 = do i <- getIState
119119 let t' = case lookupCtxtExact basefn (idris_transforms i) of
120120 Just def -> (t : def)
121121 Nothing -> [t]
122− putIState $ i { idris_transforms = addDef basefn t'
122+ putIState $ i { idris_transforms = addDef basefn t'
123123 (idris_transforms i) }
124124
125125addErrRev :: (Term, Term) -> Idris ()
@@ -130,8 +130,8 @@ totcheck :: (FC, Name) -> Idris ()
130130totcheck n = do i <- getIState; putIState $ i { idris_totcheck = idris_totcheck i ++ [n] }
131131
132132defer_totcheck :: (FC, Name) -> Idris ()
133−defer_totcheck n
134− = do i <- getIState;
133+defer_totcheck n
134+ = do i <- getIState;
135135 putIState $ i { idris_defertotcheck = nub (idris_defertotcheck i ++ [n]) }
136136
137137clear_totcheck :: Idris ()
@@ -183,7 +183,7 @@ addToCG n cg
183183 putIState $ i { idris_callgraph = addDef n cg (idris_callgraph i) }
184184
185185addTyInferred :: Name -> Idris ()
186−addTyInferred n
186+addTyInferred n
187187 = do i <- getIState
188188 putIState $ i { idris_tyinfodata =
189189 addDef n TIPartial (idris_tyinfodata i) }
@@ -197,7 +197,7 @@ addTyInfConstraints fc ts = do logLvl 2 $ "TI missing: " ++ show ts
197197 findMVApps x y
198198 = do let (fx, argsx) = unApply x
199199 let (fy, argsy) = unApply y
200− if (not (fx == fy))
200+ if (not (fx == fy))
201201 then do
202202 tryAddMV fx y
203203 tryAddMV fy x
@@ -211,17 +211,17 @@ addTyInfConstraints fc ts = do logLvl 2 $ "TI missing: " ++ show ts
211211 tryAddMV _ _ = return ()
212212
213213 addConstraintRule :: Name -> Term -> Idris ()
214− addConstraintRule n t
214+ addConstraintRule n t
215215 = do ist <- get
216216 logLvl 1 $ "TI constraint: " ++ show (n, t)
217217 case lookupCtxt n (idris_tyinfodata ist) of
218− [TISolution ts] ->
218+ [TISolution ts] ->
219219 do mapM_ (checkConsistent t) ts
220− let ti' = addDef n (TISolution (t : ts))
220+ let ti' = addDef n (TISolution (t : ts))
221221 (idris_tyinfodata ist)
222222 put $ ist { idris_tyinfodata = ti' }
223− _ ->
224− do let ti' = addDef n (TISolution [t])
223+ _ ->
224+ do let ti' = addDef n (TISolution [t])
225225 (idris_tyinfodata ist)
226226 put $ ist { idris_tyinfodata = ti' }
227227
@@ -233,14 +233,14 @@ addTyInfConstraints fc ts = do logLvl 2 $ "TI missing: " ++ show ts
233233 do let (fx, _) = unApply x
234234 let (fy, _) = unApply y
235235 case (fx, fy) of
236− (P (TCon _ _) n _, P (TCon _ _) n' _) -> errWhen (n/=n)
236+ (P (TCon _ _) n _, P (TCon _ _) n' _) -> errWhen (n/=n)
237237 (P (TCon _ _) n _, Constant _) -> errWhen True
238238 (Constant _, P (TCon _ _) n' _) -> errWhen True
239− (P (DCon _ _ _) n _, P (DCon _ _ _) n' _) -> errWhen (n/=n)
239+ (P (DCon _ _ _) n _, P (DCon _ _ _) n' _) -> errWhen (n/=n)
240240 _ -> return ()
241241
242− where errWhen True
243− = throwError (At fc
242+ where errWhen True
243+ = throwError (At fc
244244 (CantUnify False x y (Msg "") [] 0))
245245 errWhen False = return ()
246246
@@ -310,6 +310,8 @@ getNameHints i n =
310310 [ns] -> ns
311311 _ -> []
312312
313+-- Issue #1737 in the Issue Tracker.
314+-- https://github.com/idris-lang/Idris-dev/issues/1737
313315addToCalledG :: Name -> [Name] -> Idris ()
314316addToCalledG n ns = return () -- TODO
315317
@@ -333,7 +335,7 @@ addInstance int n i
333335 insI i (n : ns) | chaser n = i : n : ns
334336 | otherwise = n : insI i ns
335337
336− chaser (UN nm)
338+ chaser (UN nm)
337339 | ('@':'@':_) <- str nm = True
338340 chaser (NS n _) = chaser n
339341 chaser _ = False
@@ -421,6 +423,9 @@ withContext_ ctx name action = withContext ctx name () action
421423runIO :: IO a -> Idris a
422424runIO x = liftIO (tryIOError x) >>= either (throwError . Msg . show) return
423425-- TODO: create specific Idris exceptions for specific IO errors such as "openFile: does not exist"
426+--
427+-- Issue #1738 on the issue tracker.
428+-- https://github.com/idris-lang/Idris-dev/issues/1738
424429
425430getName :: Idris Int
426431getName = do i <- getIState;
@@ -454,9 +459,9 @@ clearOrigPats = do i <- get
454459-- the .ibc, which is all we need after all the analysis is done)
455460clearPTypes :: Idris ()
456461clearPTypes = do i <- get
457− let ctxt = tt_ctxt i
462+ let ctxt = tt_ctxt i
458463 put (i { tt_ctxt = mapDefCtxt pErase ctxt })
459− where pErase (CaseOp c t tys orig tot cds)
464+ where pErase (CaseOp c t tys orig tot cds)
460465 = CaseOp c t tys orig [] (pErase' cds)
461466 pErase x = x
462467 pErase' (CaseDefs _ (cs, c) _ rs)
@@ -503,7 +508,7 @@ addDeferred' nt ns
503508 i <- getIState
504509 putIState $ i { idris_metavars = map (\(n, (i, top, _, isTopLevel)) -> (n, (top, i, isTopLevel))) ns ++
505510 idris_metavars i }
506− where
511+ where
507512 -- 'tidyNames' is to generate user accessible names in case they are
508513 -- needed in tactic scripts
509514 tidyNames used (Bind (MN i x) b sc)
@@ -1075,12 +1080,12 @@ addStatics :: Name -> Term -> PTerm -> Idris ()
10751080addStatics n tm ptm =
10761081 do let (statics, dynamics) = initStatics tm ptm
10771082 ist <- getIState
1078− let paramnames
1083+ let paramnames
10791084 = nub $ case lookupCtxtExact n (idris_fninfo ist) of
10801085 Just p -> getNamesFrom 0 (fn_params p) tm ++
10811086 concatMap (getParamNames ist) (map snd statics)
10821087 _ -> concatMap (getParamNames ist) (map snd statics)
1083−
1088+
10841089 let stnames = nub $ concatMap freeArgNames (map snd statics)
10851090 let dnames = (nub $ concatMap freeArgNames (map snd dynamics))
10861091 \\ paramnames
@@ -1106,7 +1111,7 @@ addStatics n tm ptm =
11061111 initStatics (Bind n (Pi ty _) sc) (PPi p n' _ s)
11071112 = let (static, dynamic) = initStatics (instantiate (P Bound n ty) sc) s in
11081113 if pstatic p == Static then ((n, ty) : static, dynamic)
1109− else if (not (searchArg p))
1114+ else if (not (searchArg p))
11101115 then (static, (n, ty) : dynamic)
11111116 else (static, dynamic)
11121117 initStatics t pt = ([], [])
@@ -1116,7 +1121,7 @@ addStatics n tm ptm =
11161121 Just ti -> getNamePos 0 (param_pos ti) args
11171122 Nothing -> []
11181123 where getNamePos i ps [] = []
1119− getNamePos i ps (P _ n _ : as)
1124+ getNamePos i ps (P _ n _ : as)
11201125 | i `elem` ps = n : getNamePos (i + 1) ps as
11211126 getNamePos i ps (_ : as) = getNamePos (i + 1) ps as
11221127 getParamNames ist (Bind t (Pi (P _ n _) _) sc)
@@ -1128,7 +1133,7 @@ addStatics n tm ptm =
11281133 | otherwise = getNamesFrom (i + 1) ps sc
11291134 getNamesFrom i ps sc = []
11301135
1131− freeArgNames (Bind n (Pi ty _) sc)
1136+ freeArgNames (Bind n (Pi ty _) sc)
11321137 = nub $ freeNames ty ++ freeNames sc -- treat '->' as fn here
11331138 freeArgNames tm = let (_, args) = unApply tm in
11341139 concatMap freeNames args
@@ -1199,11 +1204,11 @@ addUsingImpls syn n fc t
11991204 let ns = implicitNamesIn (map iname uimpls) ist t
12001205 let badnames = filter (\n -> not (implicitable n) &&
12011206 n `notElem` (map iname uimpls)) ns
1202− when (not (null badnames)) $
1203− throwError (At fc (Elaborating "type of " n
1207+ when (not (null badnames)) $
1208+ throwError (At fc (Elaborating "type of " n
12041209 (NoSuchVariable (head badnames))))
1205− let cs = getArgnames t -- get already bound names
1206− let addimpls = filter (\n -> iname n `notElem` cs) uimpls
1210+ let cs = getArgnames t -- get already bound names
1211+ let addimpls = filter (\n -> iname n `notElem` cs) uimpls
12071212 -- if all names in the arguments of addconsts appear in ns,
12081213 -- add the constraint implicitly
12091214 return (bindFree ns (doAdd addimpls ns t))
@@ -1223,9 +1228,9 @@ addUsingImpls syn n fc t
12231228
12241229 -- bind the free names which weren't in the using block
12251230 bindFree [] tm = tm
1226− bindFree (n:ns) tm
1231+ bindFree (n:ns) tm
12271232 | elem n (map iname uimpls) = bindFree ns tm
1228− | otherwise
1233+ | otherwise
12291234 = PPi (Imp [] Dynamic False) n Placeholder (bindFree ns tm)
12301235
12311236 getArgnames (PPi _ n c sc)
@@ -1244,15 +1249,15 @@ getUnboundImplicits i t tm = getImps t (collectImps tm)
12441249 getImps (Bind n (Pi t _) sc) imps
12451250 | Just (p, t') <- lookup n imps = argInfo n p t' : getImps sc imps
12461251 where
1247− argInfo n (Imp opt _ _) t'
1252+ argInfo n (Imp opt _ _) t'
12481253 = (True, PImp (getPriority i t') True opt n t')
12491254 argInfo n (Exp opt _ _) t'
12501255 = (InaccessibleArg `elem` opt,
12511256 PExp (getPriority i t') opt n t')
1252− argInfo n (Constraint opt _) t'
1257+ argInfo n (Constraint opt _) t'
12531258 = (InaccessibleArg `elem` opt,
12541259 PConstraint 10 opt n t')
1255− argInfo n (TacImp opt _ scr) t'
1260+ argInfo n (TacImp opt _ scr) t'
12561261 = (InaccessibleArg `elem` opt,
12571262 PTacImplicit 10 opt n scr t')
12581263 getImps (Bind n (Pi t _) sc) imps = impBind n t : getImps sc imps
@@ -1265,6 +1270,9 @@ getUnboundImplicits i t tm = getImps t (collectImps tm)
12651270-- This has become a right mess already. Better redo it some time...
12661271-- TODO: This is obsoleted by the new way of elaborating types, but there's still
12671272-- a couple of places which use it. Clean them up!
1273+--
1274+-- Issue 1739 in the issue tracker
1275+-- https://github.com/idris-lang/Idris-dev/issues/1739
12681276implicit :: ElabInfo -> SyntaxInfo -> Name -> PTerm -> Idris PTerm
12691277implicit info syn n ptm = implicit' info syn [] n ptm
12701278
@@ -1283,11 +1291,11 @@ implicit' info syn ignore n ptm
12831291 where
12841292 -- Detect unknown names in default arguments and throw error if found.
12851293 defaultArgCheck :: [Name] -> [PArg] -> Idris ()
1286− defaultArgCheck knowns params = foldM_ notFoundInDefault knowns params
1294+ defaultArgCheck knowns params = foldM_ notFoundInDefault knowns params
12871295
12881296 notFoundInDefault :: [Name] -> PArg -> Idris [Name]
12891297 notFoundInDefault kns (PTacImplicit _ _ n script _)
1290− = do i <- getIState
1298+ = do i <- getIState
12911299 case notFound kns (namesIn [] i script) of
12921300 Nothing -> return (n:kns)
12931301 Just name -> throwError (NoSuchVariable name)
@@ -1545,7 +1553,7 @@ aiFn inpat expat qq ist fc f ds as
15451553 let nh = filter (\(n, _) -> notHidden n) ns
15461554 let ns' = case trimAlts ds nh of
15471555 [] -> nh
1548− x -> x
1556+ x -> x
15491557 case ns' of
15501558 [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef fc f') (insertImpl ns as)
15511559 [] -> if f `elem` (map fst (idris_metavars ist))
@@ -1557,7 +1565,7 @@ aiFn inpat expat qq ist fc f ds as
15571565 (insertImpl ns as)) alts
15581566 where
15591567 trimAlts [] alts = alts
1560− trimAlts ns alts
1568+ trimAlts ns alts
15611569 = filter (\(x, _) -> any (\d -> d `isPrefixOf` nspace x) ns) alts
15621570
15631571 nspace (NS _ s) = s
@@ -1612,6 +1620,8 @@ aiFn inpat expat qq ist fc f ds as
16121620 insImpAcc (M.insert n sc pnas) ps given imps
16131621 insImpAcc _ expected [] imps = imps -- so that unused implicits give error
16141622 -- TODO: report here, and prune alternatives
1623+ -- Issue #1740 in the Issue Tracker
1624+-- https://github.com/idris-lang/Idris-dev/issues/1740
16151625 insImpAcc _ _ given imps = given ++ imps
16161626
16171627 find n [] acc = Nothing
@@ -1644,7 +1654,7 @@ stripLinear i tm = evalState (sl tm) [] where
16441654 return (PPatvar fc f)
16451655 sl t@(PAlternative _ (a : as)) = do sl a
16461656 return t
1647− sl (PApp fc fn args) = do -- Just the args, fn isn't matchable as a var
1657+ sl (PApp fc fn args) = do -- Just the args, fn isn't matchable as a var
16481658 args' <- mapM slA args
16491659 return $ PApp fc fn args'
16501660 where slA (PImp p m l n t) = do t' <- sl t
@@ -1667,11 +1677,11 @@ stripUnmatchable :: IState -> PTerm -> PTerm
16671677stripUnmatchable i (PApp fc fn args) = PApp fc fn (fmap (fmap su) args) where
16681678 su :: PTerm -> PTerm
16691679 su (PRef fc f)
1670− | (Bind n (Pi t _) sc :_) <- lookupTy f (tt_ctxt i)
1680+ | (Bind n (Pi t _) sc :_) <- lookupTy f (tt_ctxt i)
16711681 = Placeholder
1672− su (PApp fc fn args)
1682+ su (PApp fc fn args)
16731683 = PApp fc fn (fmap (fmap su) args)
1674− su (PAlternative b alts)
1684+ su (PAlternative b alts)
16751685 = let alts' = filter (/= Placeholder) (map su alts) in
16761686 if null alts' then Placeholder
16771687 else PAlternative b alts'
@@ -1766,7 +1776,7 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
17661776 match (PApp _ x []) (PRef f n) = match x (PRef f n)
17671777 match (PRef _ n) tm@(PRef _ n')
17681778 | n == n' && not names &&
1769− (not (isConName n (tt_ctxt i) || isFnName n (tt_ctxt i))
1779+ (not (isConName n (tt_ctxt i) || isFnName n (tt_ctxt i))
17701780 || tm == Placeholder)
17711781 = return [(n, tm)]
17721782 -- if one namespace is missing, drop the other
@@ -1777,7 +1787,7 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
17771787 | not names && (not (isConName n (tt_ctxt i) ||
17781788 isFnName n (tt_ctxt i)) || tm == Placeholder)
17791789 = return [(n, tm)]
1780− match (PEq _ _ _ l r) (PEq _ _ _ l' r')
1790+ match (PEq _ _ _ l r) (PEq _ _ _ l' r')
17811791 = do ml <- match' l l'
17821792 mr <- match' r r'
17831793 return (ml ++ mr)
@@ -2002,5 +2012,3 @@ mkUniqueNames env tm = evalState (mkUniq tm) (S.fromList env) where
20022012 mkUniq (PProof ts) = liftM PProof (mapM mkUniqT ts)
20032013 mkUniq (PTactics ts) = liftM PTactics (mapM mkUniqT ts)
20042014 mkUniq t = return t
2005−
2006−