@@ -400,7 +400,7 @@ deriving instance Binary Plicity
401impl = Imp False Dynamic
401impl = Imp False Dynamic
402expl = Exp False Dynamic
402expl = Exp False Dynamic
403−constraint = Constraint False Static
403+constraint = Constraint False Dynamic
404tacimpl = TacImp False Dynamic
404tacimpl = TacImp False Dynamic
406data FnOpt = Inlinable | TotalFn | AssertTotal | TCGen
406data FnOpt = Inlinable | TotalFn | AssertTotal | TCGen
@@ -1055,6 +1055,30 @@ getPriority i tm = pri tm
1055 pri Placeholder = 1
1055 pri Placeholder = 1
1056 pri _ = 3
1056 pri _ = 3
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
1070+ put (i { idris_statics = addDef n stpos (idris_statics i) })
1071+ addIBC (IBCStatic n)
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 = ([], [])
1079+ staticList sts (Bind n (Pi _) sc) = (n `elem` sts) : staticList sts sc
1080+ staticList _ _ = []
1058-- Dealing with implicit arguments
1082-- Dealing with implicit arguments
1060-- Add implicit Pi bindings for any names in the term which appear in an
1084-- Add implicit Pi bindings for any names in the term which appear in an
@@ -1066,14 +1090,13 @@ implicit :: SyntaxInfo -> Name -> PTerm -> Idris PTerm
1066implicit syn n ptm
1090implicit syn n ptm
1067 = do i <- get
1091 = do i <- get
1068 let (tm', impdata) = implicitise syn i ptm
1092 let (tm', impdata) = implicitise syn i ptm
1069− let (tm'', spos) = findStatics i tm'
1093+-- let (tm'', spos) = findStatics i tm'
1070 put (i { idris_implicits = addDef n impdata (idris_implicits i) })
1094 put (i { idris_implicits = addDef n impdata (idris_implicits i) })
1071 addIBC (IBCImp n)
1095 addIBC (IBCImp n)
1072 logLvl 5 ("Implicit " ++ show n ++ " " ++ show impdata)
1096 logLvl 5 ("Implicit " ++ show n ++ " " ++ show impdata)
1073− i <- get
1097+-- i <- get
1074− put (i { idris_statics = addDef n spos (idris_statics i) })
1098+-- put (i { idris_statics = addDef n spos (idris_statics i) })
1075− addIBC (IBCStatic n)
1076− return tm''
1099+ return tm'
1078implicitise :: SyntaxInfo -> IState -> PTerm -> (PTerm, [PArg])
1101implicitise :: SyntaxInfo -> IState -> PTerm -> (PTerm, [PArg])
1079implicitise syn ist tm
1102implicitise syn ist tm
@@ -1286,21 +1309,21 @@ mkPApp fc a f as = let rest = drop a as in
1286-- FIXME: It's possible that this really has to happen after elaboration
1309-- FIXME: It's possible that this really has to happen after elaboration
1288findStatics :: IState -> PTerm -> (PTerm, [Bool])
1311findStatics :: IState -> PTerm -> (PTerm, [Bool])
1312+findStatics ist tm = trace (showImp True tm) $
1289−findStatics ist tm = let (ns, ss) = fs tm in
1313+ let (ns, ss) = fs tm in
1290 runState (pos ns ss tm) []
1314 runState (pos ns ss tm) []
1291 where fs (PPi p n t sc)
1315 where fs (PPi p n t sc)
1292 | Static <- pstatic p
1316 | Static <- pstatic p
1293 = let (ns, ss) = fs sc in
1317 = let (ns, ss) = fs sc in
1294− (namesIn [] ist t : ns, namesIn [] ist t ++ n : ss)
1318+ (namesIn [] ist t : ns, n : ss)
1295 | otherwise = let (ns, ss) = fs sc in
1319 | otherwise = let (ns, ss) = fs sc in
1296− (namesIn [] ist t : ns, ss)
1320+ (ns, ss)
1297 fs _ = ([], [])
1321 fs _ = ([], [])
1299 inOne n ns = length (filter id (map (elem n) ns)) == 1
1323 inOne n ns = length (filter id (map (elem n) ns)) == 1
1301 pos ns ss (PPi p n t sc)
1325 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
1304 spos <- get
1327 spos <- get
1305 put (True : spos)
1328 put (True : spos)
1306 return (PPi (p { pstatic = Static }) n t sc')
1329 return (PPi (p { pstatic = Static }) n t sc')