@@ -998,15 +998,15 @@ 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 hls 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 hls 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)
1007− en (PPair f p l r) = PPair f p (en l) (en r)
1008− en (PDPair f p l t r) = PDPair f p (en l) (en t) (en r)
1009− en (PAlternative ms a as) = PAlternative ms a (map en as)
1007+ en (PPair f hls p l r) = PPair f hls p (en l) (en r)
1008+ en (PDPair f hls p l t r) = PDPair f hls p (en l) (en t) (en r)
1009+ en (PAlternative ns a as) = PAlternative ns a (map en as)
10101010 en (PHidden t) = PHidden (en t)
10111011 en (PUnifyLog t) = PUnifyLog (en t)
10121012 en (PDisamb ds t) = PDisamb ds (en t)
@@ -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,10 +1103,10 @@ 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)
1108− bnames (PPair _ _ l r) = bnames l ++ bnames r
1109− bnames (PDPair _ _ l Placeholder r) = bnames l ++ bnames r
1108+ bnames (PPair _ _ _ l r) = bnames l ++ bnames r
1109+ bnames (PDPair _ _ _ l Placeholder r) = bnames l ++ bnames r
11101110 bnames _ = []
11111111
11121112-- | Expands parameters defined in parameter and where blocks inside of declarations
@@ -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
@@ -1175,9 +1175,9 @@ getPriority i tm = 1 -- pri tm
11751175 pri (PAppBind _ f as) = max 1 (max (pri f) (foldr max 0 (map (pri.getTm) as)))
11761176 pri (PCase _ f as) = max 1 (max (pri f) (foldr max 0 (map (pri.snd) as)))
11771177 pri (PTyped l r) = pri l
1178− pri (PPair _ _ l r) = max 1 (max (pri l) (pri r))
1179− pri (PDPair _ _ l t r) = max 1 (max (pri l) (max (pri t) (pri r)))
1180− pri (PAlternative ms a as) = maximum (map pri as)
1178+ pri (PPair _ _ _ l r) = max 1 (max (pri l) (pri r))
1179+ pri (PDPair _ _ _ l t r) = max 1 (max (pri l) (max (pri t) (pri r)))
1180+ pri (PAlternative _ a as) = maximum (map pri as)
11811181 pri (PConstant _ _) = 0
11821182 pri Placeholder = 1
11831183 pri _ = 3
@@ -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,
@@ -1486,15 +1486,15 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
14861486 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
14871487 imps top env (PTyped l r)
14881488 = imps top env l
1489− imps top env (PPair _ _ l r)
1489+ imps top env (PPair _ _ _ l r)
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)))))
1497− imps top env (PDPair _ _ l t r)
1497+ imps top env (PDPair _ _ _ l t r)
14981498 = do (decls, ns) <- get
14991499 let isn = namesIn uvars ist l ++ namesIn uvars ist t ++
15001500 namesIn uvars ist r
@@ -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
@@ -1559,24 +1559,24 @@ addImpl' inpat env infns imp_meths ist ptm
15591559 = let l' = ai qq env ds l
15601560 r' = ai qq env ds r in
15611561 PTyped l' r'
1562− ai qq env ds (PPair fc p l r)
1562+ ai qq env ds (PPair fc hls p l r)
15631563 = let l' = ai qq env ds l
15641564 r' = ai qq env ds r in
1565− PPair fc p l' r'
1566− ai qq env ds (PDPair fc p l t r)
1565+ PPair fc hls p l' r'
1566+ ai qq env ds (PDPair fc hls p l t r)
15671567 = let l' = ai qq env ds l
15681568 t' = ai qq env ds t
15691569 r' = ai qq env ds r in
1570− PDPair fc p l' t' r'
1570+ PDPair fc hls p l' t' r'
15711571 ai qq env ds (PAlternative ms a as)
15721572 = let as' = map (ai qq env ds) as in
15731573 PAlternative ms 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,16 @@ 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+ defs ->
1620+ ai qq env ds (PCase fc val [(PRef fc [] n, sc)])
16201621 ai qq env ds (PPi p n nfc ty sc)
16211622 = let ty' = ai qq env ds ty
16221623 env' = if n `elem` imp_meths then env
@@ -1674,7 +1675,7 @@ aiFn inpat True qq imp_meths ist fc f ffc ds []
16741675 vname _ = False
16751676
16761677aiFn inpat expat qq imp_meths ist fc f ffc ds as
1677− | f `elem` primNames = Right $ PApp fc (PRef ffc f) as
1678+ | f `elem` primNames = Right $ PApp fc (PRef ffc [ffc] f) as
16781679aiFn inpat expat qq imp_meths ist fc f ffc ds as
16791680 -- This is where namespaces get resolved by adding PAlternative
16801681 = do let ns = lookupCtxtName f (idris_implicits ist)
@@ -1683,13 +1684,13 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
16831684 [] -> nh
16841685 x -> x
16851686 case ns' of
1686− [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef ffc (isImpName f f')) (insertImpl ns as)
1687+ [(f',ns)] -> Right $ mkPApp fc (length ns) (PRef ffc [ffc] (isImpName f f')) (insertImpl ns as)
16871688 [] -> 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
1689+ then Right $ PApp fc (PRef ffc [ffc] f) as
1690+ else Right $ mkPApp fc (length as) (PRef ffc [ffc] f) as
16901691 alts -> Right $
16911692 PAlternative [] (ExactlyOne True) $
1692− map (\(f', ns) -> mkPApp fc (length ns) (PRef ffc (isImpName f f'))
1693+ map (\(f', ns) -> mkPApp fc (length ns) (PRef ffc [ffc] (isImpName f f'))
16931694 (insertImpl ns as)) alts
16941695 where
16951696 -- if the name is in imp_meths, we should actually refer to the bound
@@ -1737,7 +1738,7 @@ aiFn inpat expat qq imp_meths ist fc f ffc ds as
17371738 case find n imps [] of
17381739 Just (tm, imps') ->
17391740 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
1741+ Nothing -> let ph = if f `elem` imp_meths then PRef fc [] n else Placeholder in
17411742 PImp p True l n ph :
17421743 insImpAcc (M.insert n ph pnas) ps given imps
17431744 insImpAcc pnas (PTacImplicit p l n sc' ty : ps) given imps =
@@ -1780,14 +1781,14 @@ expArg _ = False
17801781stripLinear :: IState -> PTerm -> PTerm
17811782stripLinear i tm = evalState (sl tm) [] where
17821783 sl :: PTerm -> State [Name] PTerm
1783− sl (PRef fc f)
1784+ sl (PRef fc hl f)
17841785 | (_:_) <- lookupTy f (tt_ctxt i)
1785− = return $ PRef fc f
1786+ = return $ PRef fc hl f
17861787 | otherwise = do ns <- get
17871788 if (f `elem` ns)
1788− then return $ PHidden (PRef fc f) -- Placeholder
1789+ then return $ PHidden (PRef fc hl f) -- Placeholder
17891790 else do put (f : ns)
1790− return (PRef fc f)
1791+ return (PRef fc hl f)
17911792 sl (PPatvar fc f)
17921793 = do ns <- get
17931794 if (f `elem` ns)
@@ -1803,14 +1804,14 @@ stripLinear i tm = evalState (sl tm) [] where
18031804 as' <- slAlts ns as
18041805 return (a' : as')
18051806 slAlts ns [] = return []
1806− sl (PPair fc p l r) = do l' <- sl l; r' <- sl r; return (PPair fc p l' r')
1807− sl (PDPair fc p l t r) = do l' <- sl l
1808− t' <- sl t
1809− r' <- sl r
1810− return (PDPair fc p l' t' r')
1807+ sl (PPair fc hls p l r) = do l' <- sl l; r' <- sl r; return (PPair fc hls p l' r')
1808+ sl (PDPair fc hls p l t r) = do l' <- sl l
1809+ t' <- sl t
1810+ r' <- sl r
1811+ return (PDPair fc hls p l' t' r')
18111812 sl (PApp fc fn args) = do fn' <- case fn of
18121813 -- Just the args, fn isn't matchable as a var
1813− PRef _ _ -> return fn
1814+ PRef _ _ _ -> return fn
18141815 t -> sl t
18151816 args' <- mapM slA args
18161817 return $ PApp fc fn' args'
@@ -1832,14 +1833,14 @@ stripLinear i tm = evalState (sl tm) [] where
18321833stripUnmatchable :: IState -> PTerm -> PTerm
18331834stripUnmatchable i (PApp fc fn args) = PApp fc fn (fmap (fmap su) args) where
18341835 su :: PTerm -> PTerm
1835− su tm@(PRef fc f)
1836+ su tm@(PRef fc hl f)
18361837 | (Bind n (Pi _ t _) sc :_) <- lookupTy f (tt_ctxt i)
18371838 = Placeholder
18381839 | (TType _ : _) <- lookupTy f (tt_ctxt i)
18391840 = PHidden tm
18401841 | (UType _ : _) <- lookupTy f (tt_ctxt i)
18411842 = PHidden tm
1842− su (PApp fc f@(PRef _ fn) args)
1843+ su (PApp fc f@(PRef _ _ fn) args)
18431844 -- here we use canBeDConName because the impossible pattern
18441845 -- check will not necessarily fully resolve constructor names,
18451846 -- and these bare names will otherwise get in the way of
@@ -1852,8 +1853,8 @@ stripUnmatchable i (PApp fc fn args) = PApp fc fn (fmap (fmap su) args) where
18521853 = let alts' = filter (/= Placeholder) (map su alts) in
18531854 if null alts' then Placeholder
18541855 else PAlternative ms b alts'
1855− su (PPair fc p l r) = PPair fc p (su l) (su r)
1856− su (PDPair fc p l t r) = PDPair fc p (su l) (su t) (su r)
1856+ su (PPair fc hls p l r) = PPair fc hls p (su l) (su r)
1857+ su (PDPair fc hls p l t r) = PDPair fc hls p (su l) (su t) (su r)
18571858 su t@(PLam fc _ _ _ _) = PHidden t
18581859 su t@(PPi _ _ _ _ _) = PHidden t
18591860 su t@(PConstant _ c) | isTypeConst c = PHidden t
@@ -1877,9 +1878,8 @@ mkPApp fc a f as = let rest = drop a as in
18771878-- FIXME: It's possible that this really has to happen after elaboration
18781879
18791880findStatics :: IState -> PTerm -> (PTerm, [Bool])
1880−findStatics ist tm = trace (show tm) $
1881− let (ns, ss) = fs tm in
1882− runState (pos ns ss tm) []
1881+findStatics ist tm = let (ns, ss) = fs tm
1882+ in runState (pos ns ss tm) []
18831883 where fs (PPi p n fc t sc)
18841884 | Static <- pstatic p
18851885 = let (ns, ss) = fs sc in
@@ -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)]
@@ -1969,13 +1969,13 @@ matchClause' names i x y = checkRpts $ match (fullApp x) (fullApp y) where
19691969 return (ml ++ mr)
19701970 match (PTyped l r) x = match l x
19711971 match x (PTyped l r) = match x l
1972− match (PPair _ _ l r) (PPair _ _ l' r') = do ml <- match' l l'
1973− mr <- match' r r'
1974− return (ml ++ mr)
1975− match (PDPair _ _ l t r) (PDPair _ _ l' t' r') = do ml <- match' l l'
1976− mt <- match' t t'
1977− mr <- match' r r'
1978− return (ml ++ mt ++ mr)
1972+ match (PPair _ _ _ l r) (PPair _ _ _ l' r') = do ml <- match' l l'
1973+ mr <- match' r r'
1974+ return (ml ++ mr)
1975+ match (PDPair _ _ _ l t r) (PDPair _ _ _ l' t' r') = do ml <- match' l l'
1976+ mt <- match' t t'
1977+ mr <- match' r r'
1978+ return (ml ++ mt ++ mr)
19791979 match (PAlternative _ a as) (PAlternative _ a' as')
19801980 = do ms <- zipWithM match' as as'
19811981 return (concat ms)
@@ -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)
@@ -2058,8 +2058,8 @@ substMatchShadow n shs tm t = sm shs t where
20582058 sm xs (PRewrite f x y tm) = PRewrite f (sm xs x) (sm xs y)
20592059 (fmap (sm xs) tm)
20602060 sm xs (PTyped x y) = PTyped (sm xs x) (sm xs y)
2061− sm xs (PPair f p x y) = PPair f p (sm xs x) (sm xs y)
2062− sm xs (PDPair f p x t y) = PDPair f p (sm xs x) (sm xs t) (sm xs y)
2061+ sm xs (PPair f hls p x y) = PPair f hls p (sm xs x) (sm xs y)
2062+ sm xs (PDPair f hls p x t y) = PDPair f hls p (sm xs x) (sm xs t) (sm xs y)
20632063 sm xs (PAlternative ms a as) = PAlternative ms a (map (sm xs) as)
20642064 sm xs (PHidden x) = PHidden (sm xs x)
20652065 sm xs (PUnifyLog x) = PUnifyLog (sm xs x)
@@ -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)
@@ -2085,8 +2085,8 @@ shadow n n' t = sm t where
20852085 sm (PIfThenElse fc c t f) = PIfThenElse fc (sm c) (sm t) (sm f)
20862086 sm (PRewrite f x y tm) = PRewrite f (sm x) (sm y) (fmap sm tm)
20872087 sm (PTyped x y) = PTyped (sm x) (sm y)
2088− sm (PPair f p x y) = PPair f p (sm x) (sm y)
2089− sm (PDPair f p x t y) = PDPair f p (sm x) (sm t) (sm y)
2088+ sm (PPair f hls p x y) = PPair f hls p (sm x) (sm y)
2089+ sm (PDPair f hls p x t y) = PDPair f hls p (sm x) (sm t) (sm y)
20902090 sm (PAlternative ms a as) = PAlternative ms a (map sm as)
20912091 sm (PTactics ts) = PTactics (map (fmap sm) ts)
20922092 sm (PProof ts) = PProof (map (fmap sm) ts)
@@ -2174,10 +2174,10 @@ mkUniqueNames env shadows tm
21742174 return $! PCase fc t' alts'
21752175 mkUniq nmap (PIfThenElse fc c t f)
21762176 = liftM3 (PIfThenElse fc) (mkUniq nmap c) (mkUniq nmap t) (mkUniq nmap f)
2177− mkUniq nmap (PPair fc p l r)
2177+ mkUniq nmap (PPair fc hls p l r)
21782178 = do l' <- mkUniq nmap l; r' <- mkUniq nmap r
2179− return $! PPair fc p l' r'
2180− mkUniq nmap (PDPair fc p (PRef fc' n) t sc)
2179+ return $! PPair fc hls p l' r'
2180+ mkUniq nmap (PDPair fc hls p (PRef fc' hls' n) t sc)
21812181 | t /= Placeholder
21822182 = do env <- get
21832183 (n', sc') <- if n `S.member` env
@@ -2188,10 +2188,10 @@ mkUniqueNames env shadows tm
21882188 let nmap' = M.insert n n' nmap
21892189 t' <- mkUniq nmap t
21902190 sc'' <- mkUniq nmap' sc'
2191− return $! PDPair fc p (PRef fc' n') t' sc''
2192− mkUniq nmap (PDPair fc p l t r)
2191+ return $! PDPair fc hls p (PRef fc' hls' n') t' sc''
2192+ mkUniq nmap (PDPair fc hls p l t r)
21932193 = do l' <- mkUniq nmap l; t' <- mkUniq nmap t; r' <- mkUniq nmap r
2194− return $! PDPair fc p l' t' r'
2194+ return $! PDPair fc hls p l' t' r'
21952195 mkUniq nmap (PAlternative ns b as)
21962196 -- store the nmap and defer the rest until we've pruned the set
21972197 -- during elaboration
@@ -2207,3 +2207,4 @@ mkUniqueNames env shadows tm
22072207 where
22082208 shadowAll [] t = t
22092209 shadowAll ((n, n') : ns) t = shadow n n' (shadowAll ns t)
2210+