@@ -998,10 +998,10 @@ expandParams dec ps ns infs tm = en tm
998998 PLet fc n' nfc (en ty) (en v) (en (shadow n n' s))
999999 | otherwise = PLet fc n nfc (en ty) (en v) (en s)
10001000 -- FIXME: Should only do this in a type signature!
1001− en (PDPair f p (PRef f' n) t r)
1001+ en (PDPair f p (PRef f' fcs n) t r)
10021002 | n `elem` (map fst ps ++ ns) && t /= Placeholder
10031003 = let n' = mkShadow n in
1004− PDPair f p (PRef f' n') (en t) (en (shadow n n' r))
1004+ PDPair f p (PRef f' fcs n') (en t) (en (shadow n n' r))
10051005 en (PRewrite f l r g) = PRewrite f (en l) (en r) (fmap en g)
10061006 en (PTyped l r) = PTyped (en l) (en r)
10071007 en (PPair f p l r) = PPair f p (en l) (en r)
@@ -1017,27 +1017,27 @@ expandParams dec ps ns infs tm = en tm
10171017
10181018 en (PQuote (Var n))
10191019 | n `nselem` ns = PQuote (Var (dec n))
1020− en (PApp fc (PInferRef fc' n) as)
1021− | n `nselem` ns = PApp fc (PInferRef fc' (dec n))
1022− (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
1023− en (PApp fc (PRef fc' n) as)
1024− | n `elem` infs = PApp fc (PInferRef fc' (dec n))
1025− (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
1026− | n `nselem` ns = PApp fc (PRef fc' (dec n))
1027− (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
1028− en (PAppBind fc (PRef fc' n) as)
1029− | n `elem` infs = PAppBind fc (PInferRef fc' (dec n))
1030− (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
1031− | n `nselem` ns = PAppBind fc (PRef fc' (dec n))
1032− (map (pexp . (PRef fc)) (map fst ps) ++ (map (fmap en) as))
1033− en (PRef fc n)
1034− | n `elem` infs = PApp fc (PInferRef fc (dec n))
1035− (map (pexp . (PRef fc)) (map fst ps))
1036− | n `nselem` ns = PApp fc (PRef fc (dec n))
1037− (map (pexp . (PRef fc)) (map fst ps))
1038− en (PInferRef fc n)
1039− | n `nselem` ns = PApp fc (PInferRef fc (dec n))
1040− (map (pexp . (PRef fc)) (map fst ps))
1020+ en (PApp fc (PInferRef fc' hl n) as)
1021+ | n `nselem` ns = PApp fc (PInferRef fc' hl (dec n))
1022+ (map (pexp . (PRef fc hl)) (map fst ps) ++ (map (fmap en) as))
1023+ en (PApp fc (PRef fc' hl n) as)
1024+ | n `elem` infs = PApp fc (PInferRef fc' hl (dec n))
1025+ (map (pexp . (PRef fc hl)) (map fst ps) ++ (map (fmap en) as))
1026+ | n `nselem` ns = PApp fc (PRef fc' hl (dec n))
1027+ (map (pexp . (PRef fc hl)) (map fst ps) ++ (map (fmap en) as))
1028+ en (PAppBind fc (PRef fc' hl n) as)
1029+ | n `elem` infs = PAppBind fc (PInferRef fc' hl (dec n))
1030+ (map (pexp . (PRef fc hl)) (map fst ps) ++ (map (fmap en) as))
1031+ | n `nselem` ns = PAppBind fc (PRef fc' hl (dec n))
1032+ (map (pexp . (PRef fc hl)) (map fst ps) ++ (map (fmap en) as))
1033+ en (PRef fc hl n)
1034+ | n `elem` infs = PApp fc (PInferRef fc hl (dec n))
1035+ (map (pexp . (PRef fc hl)) (map fst ps))
1036+ | n `nselem` ns = PApp fc (PRef fc hl (dec n))
1037+ (map (pexp . (PRef fc hl)) (map fst ps))
1038+ en (PInferRef fc hl n)
1039+ | n `nselem` ns = PApp fc (PInferRef fc hl (dec n))
1040+ (map (pexp . (PRef fc hl)) (map fst ps))
10411041 en (PApp fc f as) = PApp fc (en f) (map (fmap en) as)
10421042 en (PAppBind fc f as) = PAppBind fc (en f) (map (fmap en) as)
10431043 en (PCase fc c os) = PCase fc (en c) (map (pmap en) os)
@@ -1103,7 +1103,7 @@ expandParamsD rhsonly ist dec ps ns (PClauses fc opts n cs)
11031103
11041104 removeBound lhs ns = ns \\ nub (bnames lhs)
11051105
1106− bnames (PRef _ n) = [n]
1106+ bnames (PRef _ _ n) = [n]
11071107 bnames (PApp _ _ args) = concatMap bnames (map getTm args)
11081108 bnames (PPair _ _ l r) = bnames l ++ bnames r
11091109 bnames (PDPair _ _ l Placeholder r) = bnames l ++ bnames r
@@ -1162,7 +1162,7 @@ mapsnd f (x, t) = (x, f t)
11621162getPriority :: IState -> PTerm -> Int
11631163getPriority i tm = 1 -- pri tm
11641164 where
1165− pri (PRef _ n) =
1165+ pri (PRef _ _ n) =
11661166 case lookupP n (tt_ctxt i) of
11671167 ((P (DCon _ _ _) _ _):_) -> 1
11681168 ((P (TCon _ _) _ _):_) -> 1
@@ -1288,20 +1288,20 @@ addUsingConstraints syn fc t
12881288 (mkConst c args) (doAdd cs ns t)
12891289 | otherwise = doAdd cs ns t
12901290
1291− mkConst c args = PApp fc (PRef fc c)
1292− (map (\n -> PExp 0 [] (sMN 0 "carg") (PRef fc n)) args)
1291+ mkConst c args = PApp fc (PRef fc [] c)
1292+ (map (\n -> PExp 0 [] (sMN 0 "carg") (PRef fc [] n)) args)
12931293
12941294 getConstraints (PPi (Constraint _ _) _ _ c sc)
12951295 = getcapp c ++ getConstraints sc
12961296 getConstraints (PPi _ _ _ c sc) = getConstraints sc
12971297 getConstraints _ = []
12981298
1299− getcapp (PApp _ (PRef _ c) args)
1299+ getcapp (PApp _ (PRef _ _ c) args)
13001300 = do ns <- mapM getName args
13011301 return (UConstraint c ns)
13021302 getcapp _ = []
13031303
1304− getName (PExp _ _ _ (PRef _ n)) = return n
1304+ getName (PExp _ _ _ (PRef _ _ n)) = return n
13051305 getName _ = []
13061306
13071307-- Add implicit bindings from using block, and bind any missing names
@@ -1458,7 +1458,7 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
14581458 imps True (n:env) sc
14591459 imps top env (PPi (Exp l _ _) n _ ty sc)
14601460 = do let isn = nub (implNamesIn uvars ty ++ case sc of
1461− (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
1461+ (PRef _ _ x) -> namesIn uvars ist sc `dropAll` [n]
14621462 _ -> [])
14631463 (decls, ns) <- get -- ignore decls in HO types
14641464 put (PExp (getPriority ist ty) l n Placeholder : decls,
@@ -1466,7 +1466,7 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
14661466 imps True (n:env) sc
14671467 imps top env (PPi (Constraint l _) n _ ty sc)
14681468 = do let isn = nub (implNamesIn uvars ty ++ case sc of
1469− (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
1469+ (PRef _ _ x) -> namesIn uvars ist sc `dropAll` [n]
14701470 _ -> [])
14711471 (decls, ns) <- get -- ignore decls in HO types
14721472 put (PConstraint 10 l n Placeholder : decls,
@@ -1474,7 +1474,7 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
14741474 imps True (n:env) sc
14751475 imps top env (PPi (TacImp l _ scr) n _ ty sc)
14761476 = do let isn = nub (implNamesIn uvars ty ++ case sc of
1477− (PRef _ x) -> namesIn uvars ist sc `dropAll` [n]
1477+ (PRef _ _ x) -> namesIn uvars ist sc `dropAll` [n]
14781478 _ -> [])
14791479 (decls, ns) <- get -- ignore decls in HO types
14801480 put (PTacImplicit 10 l n scr Placeholder : decls,
@@ -1490,7 +1490,7 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
14901490 = do (decls, ns) <- get
14911491 let isn = namesIn uvars ist l ++ namesIn uvars ist r
14921492 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
1493− imps top env (PDPair _ _ (PRef _ n) t r)
1493+ imps top env (PDPair _ _ (PRef _ _ n) t r)
14941494 = do (decls, ns) <- get
14951495 let isn = nub (namesIn uvars ist t ++ namesIn uvars ist r) \\ [n]
14961496 put (decls, nub (ns ++ (isn \\ (env ++ map fst (getImps decls)))))
@@ -1545,10 +1545,10 @@ addImpl' inpat env infns imp_meths ist ptm
15451545 = mkUniqueNames env (ai False (zip env (repeat Nothing)) [] ptm)
15461546 where
15471547 ai :: Bool -> [(Name, Maybe PTerm)] -> [[T.Text]] -> PTerm -> PTerm
1548− ai qq env ds (PRef fc f)
1549− | f `elem` infns = PInferRef fc f
1548+ ai qq env ds (PRef fc fcs f)
1549+ | f `elem` infns = PInferRef fc fcs f
15501550 | not (f `elem` map fst env) = handleErr $ aiFn inpat inpat qq imp_meths ist fc f fc ds []
1551− ai qq env ds (PHidden (PRef fc f))
1551+ ai qq env ds (PHidden (PRef fc hl f))
15521552 | not (f `elem` map fst env) = PHidden (handleErr $ aiFn inpat False qq imp_meths ist fc f fc ds [])
15531553 ai qq env ds (PRewrite fc l r g)
15541554 = let l' = ai qq env ds l
@@ -1572,11 +1572,11 @@ addImpl' inpat env infns imp_meths ist ptm
15721572 = let as' = map (ai qq env ds) as in
15731573 PAlternative a as'
15741574 ai qq env _ (PDisamb ds' as) = ai qq env ds' as
1575− ai qq env ds (PApp fc (PInferRef ffc f) as)
1575+ ai qq env ds (PApp fc (PInferRef ffc hl f) as)
15761576 = let as' = map (fmap (ai qq env ds)) as in
1577− PApp fc (PInferRef ffc f) as'
1578− ai qq env ds (PApp fc ftm@(PRef ffc f) as)
1579− | f `elem` infns = ai qq env ds (PApp fc (PInferRef ffc f) as)
1577+ PApp fc (PInferRef ffc hl f) as'
1578+ ai qq env ds (PApp fc ftm@(PRef ffc hl f) as)
1579+ | f `elem` infns = ai qq env ds (PApp fc (PInferRef ffc hl f) as)
15801580 | not (f `elem` map fst env)
15811581 = let as' = map (fmap (ai qq env ds)) as in
15821582 handleErr $ aiFn inpat False qq imp_meths ist fc f ffc ds as'
@@ -1608,15 +1608,15 @@ addImpl' inpat env infns imp_meths ist ptm
16081608 sc' = ai qq ((n, Just ty):env) ds sc in
16091609 PLam fc n nfc ty' sc'
16101610 _ -> ai qq env ds (PLam fc (sMN 0 "lamp") NoFC ty
1611− (PCase fc (PRef fc (sMN 0 "lamp") )
1612− [(PRef fc n, sc)]))
1611+ (PCase fc (PRef fc [] (sMN 0 "lamp") )
1612+ [(PRef fc [] n, sc)]))
16131613 ai qq env ds (PLet fc n nfc ty val sc)
16141614 = case lookupDef n (tt_ctxt ist) of
16151615 [] -> let ty' = ai qq env ds ty
16161616 val' = ai qq env ds val
16171617 sc' = ai qq ((n, Just ty):env) ds sc in
16181618 PLet fc n nfc ty' val' sc'
1619− _ -> ai qq env ds (PCase fc val [(PRef fc n, sc)])
1619+ _ -> ai qq env ds (PCase fc val [(PRef fc [] n, sc)])
16201620 ai qq env ds (PPi p n nfc ty sc)
16211621 = let ty' = ai qq env ds ty
16221622 env' = if n `elem` imp_meths then env
@@ -1674,7 +1674,7 @@ aiFn inpat True qq imp_meths ist fc f ffc ds []
16741674 vname _ = False
16751675
16761676aiFn inpat expat qq imp_meths ist fc f ffc ds as
1677− | f `elem` primNames = Right $ PApp fc (PRef ffc f) as
1677+ | f `elem` primNames = Right $ PApp fc (PRef ffc [ffc] f) as
16781678aiFn inpat expat qq imp_meths ist fc f ffc ds as
16791679 -- This is where namespaces get resolved by adding PAlternative
16801680 = do let ns = lookupCtxtName f (idris_implicits ist)
@@ -1683,13 +1683,13 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
16831683 [] -> nh
16841684 x -> x
16851685 case ns' of
1686− [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef ffc (isImpName f f')) (insertImpl ns as)
1686+ [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef ffc [ffc] (isImpName f f')) (insertImpl ns as)
16871687 [] -> if f `elem` (map fst (idris_metavars ist))
1688− then Right $ PApp fc (PRef ffc f) as
1689− else Right $ mkPApp fc (length as) (PRef ffc f) as
1688+ then Right $ PApp fc (PRef ffc [ffc] f) as
1689+ else Right $ mkPApp fc (length as) (PRef ffc [ffc] f) as
16901690 alts -> Right $
16911691 PAlternative (ExactlyOne True) $
1692− map (\(f', ns) -> mkPApp fc (length ns) (PRef ffc (isImpName f f'))
1692+ map (\(f', ns) -> mkPApp fc (length ns) (PRef ffc [ffc] (isImpName f f'))
16931693 (insertImpl ns as)) alts
16941694 where
16951695 -- if the name is in imp_meths, we should actually refer to the bound
@@ -1737,7 +1737,7 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
17371737 case find n imps [] of
17381738 Just (tm, imps') ->
17391739 PImp p False l n tm : insImpAcc (M.insert n tm pnas) ps given imps'
1740− Nothing -> let ph = if f `elem` imp_meths then PRef fc n else Placeholder in
1740+ Nothing -> let ph = if f `elem` imp_meths then PRef fc [] n else Placeholder in
17411741 PImp p True l n ph :
17421742 insImpAcc (M.insert n ph pnas) ps given imps
17431743 insImpAcc pnas (PTacImplicit p l n sc' ty : ps) given imps =
@@ -1780,14 +1780,14 @@ expArg _ = False
17801780stripLinear :: IState -> PTerm -> PTerm
17811781stripLinear i tm = evalState (sl tm) [] where
17821782 sl :: PTerm -> State [Name] PTerm
1783− sl (PRef fc f)
1783+ sl (PRef fc hl f)
17841784 | (_:_) <- lookupTy f (tt_ctxt i)
1785− = return $ PRef fc f
1785+ = return $ PRef fc hl f
17861786 | otherwise = do ns <- get
17871787 if (f `elem` ns)
1788− then return $ PHidden (PRef fc f) -- Placeholder
1788+ then return $ PHidden (PRef fc hl f) -- Placeholder
17891789 else do put (f : ns)
1790− return (PRef fc f)
1790+ return (PRef fc hl f)
17911791 sl (PPatvar fc f)
17921792 = do ns <- get
17931793 if (f `elem` ns)
@@ -1810,7 +1810,7 @@ stripLinear i tm = evalState (sl tm) [] where
18101810 return (PDPair fc p l' t' r')
18111811 sl (PApp fc fn args) = do fn' <- case fn of
18121812 -- Just the args, fn isn't matchable as a var
1813− PRef _ _ -> return fn
1813+ PRef _ _ _ -> return fn
18141814 t -> sl t
18151815 args' <- mapM slA args
18161816 return $ PApp fc fn' args'
@@ -1832,14 +1832,14 @@ stripLinear i tm = evalState (sl tm) [] where
18321832stripUnmatchable :: IState -> PTerm -> PTerm
18331833stripUnmatchable i (PApp fc fn args) = PApp fc fn (fmap (fmap su) args) where
18341834 su :: PTerm -> PTerm
1835− su tm@(PRef fc f)
1835+ su tm@(PRef fc hl f)
18361836 | (Bind n (Pi _ t _) sc :_) <- lookupTy f (tt_ctxt i)
18371837 = Placeholder
18381838 | (TType _ : _) <- lookupTy f (tt_ctxt i)
18391839 = PHidden tm
18401840 | (UType _ : _) <- lookupTy f (tt_ctxt i)
18411841 = PHidden tm
1842− su (PApp fc f@(PRef _ fn) args)
1842+ su (PApp fc f@(PRef _ _ fn) args)
18431843 -- here we use canBeDConName because the impossible pattern
18441844 -- check will not necessarily fully resolve constructor names,
18451845 -- and these bare names will otherwise get in the way of
@@ -1930,24 +1930,24 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
19301930 fullApp x = x
19311931
19321932 match' x y = match (fullApp x) (fullApp y)
1933− match (PApp _ (PRef _ (NS (UN fi) [b])) [_,_,x]) x'
1933+ match (PApp _ (PRef _ _ (NS (UN fi) [b])) [_,_,x]) x'
19341934 | fi == txt "fromInteger" && b == txt "builtins",
19351935 PConstant _ (I _) <- getTm x = match (getTm x) x'
1936− match x' (PApp _ (PRef _ (NS (UN fi) [b])) [_,_,x])
1936+ match x' (PApp _ (PRef _ _ (NS (UN fi) [b])) [_,_,x])
19371937 | fi == txt "fromInteger" && b == txt "builtins",
19381938 PConstant _ (I _) <- getTm x = match (getTm x) x'
1939− match (PApp _ (PRef _ (UN l)) [_,x]) x' | l == txt "lazy" = match (getTm x) x'
1940− match x (PApp _ (PRef _ (UN l)) [_,x']) | l == txt "lazy" = match x (getTm x')
1939+ match (PApp _ (PRef _ _ (UN l)) [_,x]) x' | l == txt "lazy" = match (getTm x) x'
1940+ match x (PApp _ (PRef _ _ (UN l)) [_,x']) | l == txt "lazy" = match x (getTm x')
19411941 match (PApp _ f args) (PApp _ f' args')
19421942 | length args == length args'
19431943 = do mf <- match' f f'
19441944 ms <- zipWithM matchArg args args'
19451945 return (mf ++ concat ms)
1946− match (PRef f n) (PApp _ x []) = match (PRef f n) x
1947− match (PPatvar f n) xr = match (PRef f n) xr
1948− match xr (PPatvar f n) = match xr (PRef f n)
1949− match (PApp _ x []) (PRef f n) = match x (PRef f n)
1950− match (PRef _ n) tm@(PRef _ n')
1946+ match (PRef f hl n) (PApp _ x []) = match (PRef f hl n) x
1947+ match (PPatvar f n) xr = match (PRef f [f] n) xr
1948+ match xr (PPatvar f n) = match xr (PRef f [f] n)
1949+ match (PApp _ x []) (PRef f hl n) = match x (PRef f hl n)
1950+ match (PRef _ _ n) tm@(PRef _ _ n')
19511951 | n == n' && not names &&
19521952 (not (isConName n (tt_ctxt i) || isFnName n (tt_ctxt i))
19531953 || tm == Placeholder)
@@ -1956,7 +1956,7 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
19561956 | n == n' || n == dropNS n' || dropNS n == n' = return []
19571957 where dropNS (NS n _) = n
19581958 dropNS n = n
1959− match (PRef _ n) tm
1959+ match (PRef _ _ n) tm
19601960 | not names && (not (isConName n (tt_ctxt i) ||
19611961 isFnName n (tt_ctxt i)) || tm == Placeholder)
19621962 = return [(n, tm)]
@@ -1986,7 +1986,7 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
19861986 _ -> LeftErr (a, b)
19871987 match (PCase _ _ _) _ = return [] -- lifted out
19881988 match (PMetavar _ _) _ = return [] -- modified
1989− match (PInferRef _ _) _ = return [] -- modified
1989+ match (PInferRef _ _ _) _ = return [] -- modified
19901990 match (PQuote _) _ = return []
19911991 match (PProof _) _ = return []
19921992 match (PTactics _) _ = return []
@@ -2044,13 +2044,13 @@ substMatch n = substMatchShadow n []
20442044
20452045substMatchShadow :: Name -> [Name] -> PTerm -> PTerm -> PTerm
20462046substMatchShadow n shs tm t = sm shs t where
2047− sm xs (PRef _ n') | n == n' = tm
2047+ sm xs (PRef _ _ n') | n == n' = tm
20482048 sm xs (PLam fc x xfc t sc) = PLam fc x xfc (sm xs t) (sm xs sc)
20492049 sm xs (PPi p x fc t sc)
20502050 | x `elem` xs
20512051 = let x' = nextName x in
2052− PPi p x' fc (sm (x':xs) (substMatch x (PRef emptyFC x') t))
2053− (sm (x':xs) (substMatch x (PRef emptyFC x') sc))
2052+ PPi p x' fc (sm (x':xs) (substMatch x (PRef emptyFC [] x') t))
2053+ (sm (x':xs) (substMatch x (PRef emptyFC [] x') sc))
20542054 | otherwise = PPi p x fc (sm xs t) (sm (x : xs) sc)
20552055 sm xs (PApp f x as) = fullApp $ PApp f (sm xs x) (map (fmap (sm xs)) as)
20562056 sm xs (PCase f x as) = PCase f (sm xs x) (map (pmap (sm xs)) as)
@@ -2072,7 +2072,7 @@ substMatchShadow n shs tm t = sm shs t where
20722072
20732073shadow :: Name -> Name -> PTerm -> PTerm
20742074shadow n n' t = sm t where
2075− sm (PRef fc x) | n == x = PRef fc n'
2075+ sm (PRef fc hl x) | n == x = PRef fc hl n'
20762076 sm (PLam fc x xfc t sc) | n /= x = PLam fc x xfc (sm t) (sm sc)
20772077 | otherwise = PLam fc x xfc (sm t) sc
20782078 sm (PPi p x fc t sc) | n /= x = PPi p x fc (sm t) (sm sc)
@@ -2170,7 +2170,7 @@ mkUniqueNames env tm = evalState (mkUniq tm) (S.fromList env) where
21702170 mkUniq (PPair fc p l r)
21712171 = do l' <- mkUniq l; r' <- mkUniq r
21722172 return $! PPair fc p l' r'
2173− mkUniq (PDPair fc p (PRef fc' n) t sc)
2173+ mkUniq (PDPair fc p (PRef fc' hl n) t sc)
21742174 | t /= Placeholder
21752175 = do env <- get
21762176 (n', sc') <- if n `S.member` env
@@ -2180,7 +2180,7 @@ mkUniqueNames env tm = evalState (mkUniq tm) (S.fromList env) where
21802180 put (S.insert n' env)
21812181 t' <- mkUniq t
21822182 sc'' <- mkUniq sc'
2183− return $! PDPair fc p (PRef fc' n') t' sc''
2183+ return $! PDPair fc p (PRef fc' hl n') t' sc''
21842184 mkUniq (PDPair fc p l t r)
21852185 = do l' <- mkUniq l; t' <- mkUniq t; r' <- mkUniq r
21862186 return $! PDPair fc p l' t' r'