@@ -533,6 +533,7 @@ data PTerm = PQuote Raw
533 | PLet Name PTerm PTerm PTerm
533 | PLet Name PTerm PTerm PTerm
534 | PTyped PTerm PTerm -- ^ Term with explicit type
534 | PTyped PTerm PTerm -- ^ Term with explicit type
535 | PApp FC PTerm [PArg]
535 | PApp FC PTerm [PArg]
536+ | PAppBind FC PTerm [PArg] -- ^ implicitly bound application
536 | PMatchApp FC Name -- ^ Make an application by type matching
537 | PMatchApp FC Name -- ^ Make an application by type matching
537 | PCase FC PTerm [(PTerm, PTerm)]
538 | PCase FC PTerm [(PTerm, PTerm)]
538 | PTrue FC
539 | PTrue FC
@@ -573,6 +574,7 @@ mapPT f t = f (mpt t) where
573 mpt (PRewrite fc t s g) = PRewrite fc (mapPT f t) (mapPT f s)
574 mpt (PRewrite fc t s g) = PRewrite fc (mapPT f t) (mapPT f s)
574 (fmap (mapPT f) g)
575 (fmap (mapPT f) g)
575 mpt (PApp fc t as) = PApp fc (mapPT f t) (map (fmap (mapPT f)) as)
576 mpt (PApp fc t as) = PApp fc (mapPT f t) (map (fmap (mapPT f)) as)
577+ mpt (PAppBind fc t as) = PAppBind fc (mapPT f t) (map (fmap (mapPT f)) as)
576 mpt (PCase fc c os) = PCase fc (mapPT f c) (map (pmap (mapPT f)) os)
578 mpt (PCase fc c os) = PCase fc (mapPT f c) (map (pmap (mapPT f)) os)
577 mpt (PEq fc l r) = PEq fc (mapPT f l) (mapPT f r)
579 mpt (PEq fc l r) = PEq fc (mapPT f l) (mapPT f r)
578 mpt (PTyped l r) = PTyped (mapPT f l) (mapPT f r)
580 mpt (PTyped l r) = PTyped (mapPT f l) (mapPT f r)
@@ -957,6 +959,8 @@ prettyImp impl = prettySe 10
957 rbrace <+> text "->" <+> prettySe 10 sc
959 rbrace <+> text "->" <+> prettySe 10 sc
958 prettySe p (PApp _ (PRef _ f) [])
960 prettySe p (PApp _ (PRef _ f) [])
959 | not impl = pretty f
961 | not impl = pretty f
962+ prettySe p (PAppBind _ (PRef _ f) [])
963+ | not impl = pretty f <+> text "!"
960 prettySe p (PApp _ (PRef _ op@(UN (f:_))) args)
964 prettySe p (PApp _ (PRef _ op@(UN (f:_))) args)
961 | length (getExps args) == 2 && (not impl) && (not $ isAlpha f) =
965 | length (getExps args) == 2 && (not impl) && (not $ isAlpha f) =
962 let [l, r] = getExps args in
966 let [l, r] = getExps args in
@@ -1142,6 +1146,8 @@ showImp ist impl colour tm = se 10 [] tm where
1142 se p bnd (PMatchApp _ f) = "match " ++ show f
1146 se p bnd (PMatchApp _ f) = "match " ++ show f
1143 se p bnd (PApp _ hd@(PRef _ f) [])
1147 se p bnd (PApp _ hd@(PRef _ f) [])
1144 | not impl = se p bnd hd
1148 | not impl = se p bnd hd
1149+ se p bnd (PAppBind _ hd@(PRef _ f) [])
1150+ | not impl = se p bnd hd ++ "!"
1145 se p bnd (PApp _ op@(PRef _ (UN (f:_))) args)
1151 se p bnd (PApp _ op@(PRef _ (UN (f:_))) args)
1146 | length (getExps args) == 2 && not impl && not (isAlpha f)
1152 | length (getExps args) == 2 && not impl && not (isAlpha f)
1147 = let [l, r] = getExps args in
1153 = let [l, r] = getExps args in
@@ -1150,6 +1156,10 @@ showImp ist impl colour tm = se 10 [] tm where
1150 = let args = getExps as in
1156 = let args = getExps as in
1151 bracket p 1 $ se 1 bnd f ++ if impl then concatMap (sArg bnd) as
1157 bracket p 1 $ se 1 bnd f ++ if impl then concatMap (sArg bnd) as
1152 else concatMap (seArg bnd) args
1158 else concatMap (seArg bnd) args
1159+ se p bnd (PAppBind _ f as)
1160+ = let args = getExps as in
1161+ bracket p 1 $ se 1 bnd f ++ "!" ++ if impl then concatMap (sArg bnd) as
1162+ else concatMap (seArg bnd) args
1153 se p bnd (PCase _ scr opts) = "case " ++ se 10 bnd scr ++ " of " ++ showSep " | " (map sc opts)
1163 se p bnd (PCase _ scr opts) = "case " ++ se 10 bnd scr ++ " of " ++ showSep " | " (map sc opts)
1154 where sc (l, r) = se 10 bnd l ++ " => " ++ se 10 bnd r
1164 where sc (l, r) = se 10 bnd l ++ " => " ++ se 10 bnd r
1155 se p bnd (PHidden tm) = "." ++ se 0 bnd tm
1165 se p bnd (PHidden tm) = "." ++ se 0 bnd tm
@@ -1238,6 +1248,7 @@ instance Sized PTerm where
1238 size (PLet name ty def bdy) = 1 + size ty + size def + size bdy
1248 size (PLet name ty def bdy) = 1 + size ty + size def + size bdy
1239 size (PTyped trm ty) = 1 + size trm + size ty
1249 size (PTyped trm ty) = 1 + size trm + size ty
1240 size (PApp fc name args) = 1 + size args
1250 size (PApp fc name args) = 1 + size args
1251+ size (PAppBind fc name args) = 1 + size args
1241 size (PCase fc trm bdy) = 1 + size trm + size bdy
1252 size (PCase fc trm bdy) = 1 + size trm + size bdy
1242 size (PTrue fc) = 1
1253 size (PTrue fc) = 1
1243 size (PFalse fc) = 1
1254 size (PFalse fc) = 1
@@ -1274,6 +1285,7 @@ allNamesIn tm = nub $ ni [] tm
1274 ni env (PRef _ n)
1285 ni env (PRef _ n)
1275 | not (n `elem` env) = [n]
1286 | not (n `elem` env) = [n]
1276 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1287 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1288+ ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1277 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1289 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1278 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1290 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1279 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1291 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
@@ -1300,6 +1312,7 @@ namesIn uvars ist tm = nub $ ni [] tm
1300 [] -> [n]
1312 [] -> [n]
1301 _ -> if n `elem` (map fst uvars) then [n] else []
1313 _ -> if n `elem` (map fst uvars) then [n] else []
1302 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1314 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1315+ ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1303 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1316 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1304 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1317 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1305 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1318 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
@@ -1326,6 +1339,7 @@ usedNamesIn vars ist tm = nub $ ni [] tm
1326 [] -> [n]
1339 [] -> [n]
1328 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1341 ni env (PApp _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1342+ ni env (PAppBind _ f as) = ni env f ++ concatMap (ni env) (map getTm as)
1329 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1343 ni env (PCase _ c os) = ni env c ++ concatMap (ni env) (map snd os)
1330 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1344 ni env (PLam n ty sc) = ni env ty ++ ni (n:env) sc
1331 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc
1345 ni env (PPi _ n ty sc) = ni env ty ++ ni (n:env) sc