@@ -397,12 +397,15 @@ elabPE info fc caller r =
397 [Total _] -> 65536
397 [Total _] -> 65536
398 [Productive] -> 16
398 [Productive] -> 16
400+ let specnames = mapMaybe (specName (pe_simple specdecl))
402+ descs <- mapM getStaticsFrom (map fst specnames)
400 let opts = [Specialise ((if pe_simple specdecl
404 let opts = [Specialise ((if pe_simple specdecl
401 then map (\x -> (x, Nothing)) cgns'
405 then map (\x -> (x, Nothing)) cgns'
402 else []) ++
406 else []) ++
403− (n, Just maxred) :
407+ (n, Just maxred) : specnames ++
404− mapMaybe (specName (pe_simple specdecl))
408+ concat descs)]
406 logElab 3 $ "Specialising application: " ++ show specapp
409 logElab 3 $ "Specialising application: " ++ show specapp
407 ++ " in " ++ show caller ++
410 ++ " in " ++ show caller ++
408 " with " ++ show opts
411 " with " ++ show opts
@@ -443,6 +446,20 @@ elabPE info fc caller r =
443 | (P Ref n _, _) <- unApply tm = Just (n, Just (if simpl then 1 else 0))
446 | (P Ref n _, _) <- unApply tm = Just (n, Just (if simpl then 1 else 0))
444 specName simpl _ = Nothing
447 specName simpl _ = Nothing
449+ -- get the descendants of the name 'n' which are marked %static
450+ -- Marking a function %static essentially means it's used to construct
451+ -- programs, so should be evaluated by the partial evaluator
452+ getStaticsFrom :: Name -> Idris [(Name, Maybe Int)]
453+ getStaticsFrom n = do ns <- getAllNames n
455+ let statics = filter (staticFn i) ns
456+ return (map (\n -> (n, Nothing)) statics)
458+ staticFn :: IState -> Name -> Bool
459+ staticFn i n = case lookupCtxt n (idris_flags i) of
460+ [opts] -> elem StaticFn opts
446 notStatic ist n = case lookupCtxtExact n (idris_statics ist) of
463 notStatic ist n = case lookupCtxtExact n (idris_statics ist) of
447 Just s -> not (or s)
464 Just s -> not (or s)
448 _ -> True
465 _ -> True