@@ -400,7 +400,7 @@ deriving instance Binary Plicity
400400
401401impl = Imp False Dynamic
402402expl = Exp False Dynamic
403−constraint = Constraint False Static
403+constraint = Constraint False Dynamic
404404tacimpl = TacImp False Dynamic
405405
406406data FnOpt = Inlinable | TotalFn | AssertTotal | TCGen
@@ -1055,6 +1055,30 @@ getPriority i tm = pri tm
10551055 pri Placeholder = 1
10561056 pri _ = 3
10571057
1058+addStatics :: Name -> Term -> PTerm -> Idris ()
1059+addStatics n tm ptm =
1060+ do let (statics, dynamics) = initStatics tm ptm
1061+ let stnames = nub $ concatMap freeNames (map snd statics)
1062+ let dnames = nub $ concatMap freeNames (map snd dynamics)
1063+ when (not (null statics)) $
1064+ logLvl 7 $ show n ++ " " ++ show statics ++ "\n" ++ show dynamics
1065+ ++ "\n" ++ show stnames ++ "\n" ++ show dnames
1066+ let statics' = nub $ map fst statics ++
1067+ filter (\x -> not (elem x dnames)) stnames
1068+ let stpos = staticList statics' tm
1069+ i <- get
1070+ put (i { idris_statics = addDef n stpos (idris_statics i) })
1071+ addIBC (IBCStatic n)
1072+ where
1073+ initStatics (Bind n (Pi ty) sc) (PPi p _ _ s)
1074+ = let (static, dynamic) = initStatics (instantiate (P Bound n ty) sc) s in
1075+ if pstatic p == Static then ((n, ty) : static, dynamic)
1076+ else (static, (n, ty) : dynamic)
1077+ initStatics t pt = ([], [])
1078+
1079+ staticList sts (Bind n (Pi _) sc) = (n `elem` sts) : staticList sts sc
1080+ staticList _ _ = []
1081+
10581082-- Dealing with implicit arguments
10591083
10601084-- Add implicit Pi bindings for any names in the term which appear in an
@@ -1066,14 +1090,13 @@ implicit :: SyntaxInfo -> Name -> PTerm -> Idris PTerm
10661090implicit syn n ptm
10671091 = do i <- get
10681092 let (tm', impdata) = implicitise syn i ptm
1069− let (tm'', spos) = findStatics i tm'
1093+-- let (tm'', spos) = findStatics i tm'
10701094 put (i { idris_implicits = addDef n impdata (idris_implicits i) })
10711095 addIBC (IBCImp n)
10721096 logLvl 5 ("Implicit " ++ show n ++ " " ++ show impdata)
1073− i <- get
1074− put (i { idris_statics = addDef n spos (idris_statics i) })
1075− addIBC (IBCStatic n)
1076− return tm''
1097+-- i <- get
1098+-- put (i { idris_statics = addDef n spos (idris_statics i) })
1099+ return tm'
10771100
10781101implicitise :: SyntaxInfo -> IState -> PTerm -> (PTerm, [PArg])
10791102implicitise syn ist tm
@@ -1286,21 +1309,21 @@ mkPApp fc a f as = let rest = drop a as in
12861309-- FIXME: It's possible that this really has to happen after elaboration
12871310
12881311findStatics :: IState -> PTerm -> (PTerm, [Bool])
1289−findStatics ist tm = let (ns, ss) = fs tm in
1312+findStatics ist tm = trace (showImp True tm) $
1313+ let (ns, ss) = fs tm in
12901314 runState (pos ns ss tm) []
12911315 where fs (PPi p n t sc)
12921316 | Static <- pstatic p
12931317 = let (ns, ss) = fs sc in
1294− (namesIn [] ist t : ns, namesIn [] ist t ++ n : ss)
1318+ (namesIn [] ist t : ns, n : ss)
12951319 | otherwise = let (ns, ss) = fs sc in
1296− (namesIn [] ist t : ns, ss)
1320+ (ns, ss)
12971321 fs _ = ([], [])
12981322
12991323 inOne n ns = length (filter id (map (elem n) ns)) == 1
13001324
13011325 pos ns ss (PPi p n t sc)
1302− | n `inOne` ns && elem n ss
1303− = do sc' <- pos ns ss sc
1326+ | elem n ss = do sc' <- pos ns ss sc
13041327 spos <- get
13051328 put (True : spos)
13061329 return (PPi (p { pstatic = Static }) n t sc')