@@ -679,9 +679,13 @@ deriving instance NFData Raw
679679-- the types of bindings (and their values, if any); the attached identifiers are part
680680-- of the 'Bind' constructor for the 'TT' type.
681681data Binder b = Lam { binderTy :: !b {-^ type annotation for bound variable-}}
682− | Pi { binderTy :: !b,
682+ | Pi { binderImpl :: Bool,
683+ binderTy :: !b,
683684 binderKind :: !b }
684− {-^ A binding that occurs in a function type expression, e.g. @(x:Int) -> ...@ -}
685+ {-^ A binding that occurs in a function type expression, e.g. @(x:Int) -> ...@
686+ The 'binderImpl' flag says whether it was a scoped implicit
687+ (i.e. forall bound) in the high level Idris, but otherwise
688+ has no relevance in TT. -}
685689 | Let { binderTy :: !b,
686690 binderVal :: b {-^ value for bound variable-}}
687691 -- ^ A binding that occurs in a @let@ expression
@@ -703,7 +707,7 @@ deriving instance NFData Binder
703707
704708instance Sized a => Sized (Binder a) where
705709 size (Lam ty) = 1 + size ty
706− size (Pi ty _) = 1 + size ty
710+ size (Pi _ ty _) = 1 + size ty
707711 size (Let ty val) = 1 + size ty + size val
708712 size (NLet ty val) = 1 + size ty + size val
709713 size (Hole ty) = 1 + size ty
@@ -717,7 +721,7 @@ fmapMB f (Let t v) = liftM2 Let (f t) (f v)
717721fmapMB f (NLet t v) = liftM2 NLet (f t) (f v)
718722fmapMB f (Guess t v) = liftM2 Guess (f t) (f v)
719723fmapMB f (Lam t) = liftM Lam (f t)
720−fmapMB f (Pi t k) = liftM2 Pi (f t) (f k)
724+fmapMB f (Pi i t k) = liftM2 (Pi i) (f t) (f k)
721725fmapMB f (Hole t) = liftM Hole (f t)
722726fmapMB f (GHole i t) = liftM (GHole i) (f t)
723727fmapMB f (PVar t) = liftM PVar (f t)
@@ -884,7 +888,7 @@ isInjective (P (DCon _ _ _) _ _) = True
884888isInjective (P (TCon _ _) _ _) = True
885889isInjective (Constant _) = True
886890isInjective (TType x) = True
887−isInjective (Bind _ (Pi _ _) sc) = True
891+isInjective (Bind _ (Pi _ _ _) sc) = True
888892isInjective (App f a) = isInjective f
889893isInjective _ = False
890894
@@ -1099,7 +1103,7 @@ freeNames t = nub $ freeNames' t
10991103
11001104-- | Return the arity of a (normalised) type
11011105arity :: TT n -> Int
1102−arity (Bind n (Pi t _) sc) = 1 + arity sc
1106+arity (Bind n (Pi _ t _) sc) = 1 + arity sc
11031107arity _ = 0
11041108
11051109-- | Deconstruct an application; returns the function and a list of arguments
@@ -1159,13 +1163,13 @@ bindTyArgs b xs = bindAll (map (\ (n, ty) -> (n, b ty)) xs)
11591163getArgTys :: TT n -> [(n, TT n)]
11601164getArgTys (Bind n (PVar _) sc) = getArgTys sc
11611165getArgTys (Bind n (PVTy _) sc) = getArgTys sc
1162−getArgTys (Bind n (Pi t _) sc) = (n, t) : getArgTys sc
1166+getArgTys (Bind n (Pi _ t _) sc) = (n, t) : getArgTys sc
11631167getArgTys _ = []
11641168
11651169getRetTy :: TT n -> TT n
11661170getRetTy (Bind n (PVar _) sc) = getRetTy sc
11671171getRetTy (Bind n (PVTy _) sc) = getRetTy sc
1168−getRetTy (Bind n (Pi _ _) sc) = getRetTy sc
1172+getRetTy (Bind n (Pi _ _ _) sc) = getRetTy sc
11691173getRetTy sc = sc
11701174
11711175uniqueNameFrom :: [Name] -> [Name] -> Name
@@ -1281,7 +1285,7 @@ prettyEnv env t = prettyEnv' env t False
12811285 else
12821286 lbracket <+> text (show i) <+> rbracket
12831287 | otherwise = text "unbound" <+> text (show i) <+> text "!"
1284− prettySe p env (Bind n b@(Pi t _) sc) debug
1288+ prettySe p env (Bind n b@(Pi _ t _) sc) debug
12851289 | noOccurrence n sc && not debug =
12861290 bracket p 2 $ prettySb env n b debug <> prettySe 10 ((n, b):env) sc debug
12871291 prettySe p env (Bind n b sc) debug =
@@ -1297,7 +1301,7 @@ prettyEnv env t = prettyEnv' env t False
12971301 -- Render a `Binder` and its name
12981302 prettySb env n (Lam t) = prettyB env "λ" "=>" n t
12991303 prettySb env n (Hole t) = prettyB env "?defer" "." n t
1300− prettySb env n (Pi t _) = prettyB env "(" ") ->" n t
1304+ prettySb env n (Pi _ t _) = prettyB env "(" ") ->" n t
13011305 prettySb env n (PVar t) = prettyB env "pat" "." n t
13021306 prettySb env n (PVTy t) = prettyB env "pty" "." n t
13031307 prettySb env n (Let t v) = prettyBv env "let" "in" n t v
@@ -1323,7 +1327,7 @@ showEnv' env t dbg = se 10 env t where
13231327 = (show $ fst $ env!!i) ++
13241328 if dbg then "{" ++ show i ++ "}" else ""
13251329 | otherwise = "!!V " ++ show i ++ "!!"
1326− se p env (Bind n b@(Pi t k) sc)
1330+ se p env (Bind n b@(Pi _ t k) sc)
13271331 | noOccurrence n sc && not dbg = bracket p 2 $ se 1 env t ++ arrow k ++ se 10 ((n,b):env) sc
13281332 where arrow (TType _) = " -> "
13291333 arrow u = " [" ++ show u ++ "] -> "
@@ -1339,7 +1343,7 @@ showEnv' env t dbg = se 10 env t where
13391343 sb env n (Lam t) = showb env "\\ " " => " n t
13401344 sb env n (Hole t) = showb env "? " ". " n t
13411345 sb env n (GHole i t) = showb env "?defer " ". " n t
1342− sb env n (Pi t _) = showb env "(" ") -> " n t
1346+ sb env n (Pi _ t _) = showb env "(" ") -> " n t
13431347 sb env n (PVar t) = showb env "pat " ". " n t
13441348 sb env n (PVTy t) = showb env "pty " ". " n t
13451349 sb env n (Let t v) = showbv env "let " " in " n t v
@@ -1399,7 +1403,7 @@ orderPats tm = op [] tm
13991403
14001404 op ps (Bind n (PVar t) sc) = op ((n, PVar t) : ps) sc
14011405 op ps (Bind n (Hole t) sc) = op ((n, Hole t) : ps) sc
1402− op ps (Bind n (Pi t k) sc) = op ((n, Pi t k) : ps) sc
1406+ op ps (Bind n (Pi i t k) sc) = op ((n, Pi i t k) : ps) sc
14031407 op ps sc = bindAll (sortP ps) sc
14041408
14051409 sortP ps = pick [] (reverse ps)
@@ -1445,10 +1449,10 @@ liftPats tm = let (tm', ps) = runState (getPats tm) [] in
14451449 v' <- getPats v
14461450 sc' <- getPats sc
14471451 return (Bind n (Let t' v') sc')
1448− getPats (Bind n (Pi t k) sc) = do t' <- getPats t
1449− k' <- getPats k
1450− sc' <- getPats sc
1451− return (Bind n (Pi t' k') sc')
1452+ getPats (Bind n (Pi i t k) sc) = do t' <- getPats t
1453+ k' <- getPats k
1454+ sc' <- getPats sc
1455+ return (Bind n (Pi i t' k') sc')
14521456 getPats (Bind n (Lam t) sc) = do t' <- getPats t
14531457 sc' <- getPats sc
14541458 return (Bind n (Lam t') sc')