comparison src/sqlcache.sml @ 2259:6951a645ccdf

Fix effectfulness registration toy cache.
author Ziv Scully <ziv@mit.edu>
date Sun, 27 Sep 2015 17:24:57 -0400
parents b1ba35ce2613
children 03b10c7fab9a
comparison
equal deleted inserted replaced
2258:b1ba35ce2613 2259:6951a645ccdf
39 "urlifyFloat_w", 39 "urlifyFloat_w",
40 "urlifyString_w", 40 "urlifyString_w",
41 "urlifyBool_w", 41 "urlifyBool_w",
42 "urlifyChannel_w"] 42 "urlifyChannel_w"]
43 in 43 in
44 (* ASK: nicer way than using [Settings.addEffectful] for each Sqlcache
45 function? Right now they're all always effectful. *)
44 fn (m, f) => Settings.isEffectful (m, f) 46 fn (m, f) => Settings.isEffectful (m, f)
45 andalso not (m = "Basis" andalso SS.member (okayWrites, f)) 47 andalso not (m = "Basis" andalso SS.member (okayWrites, f))
46 end 48 end
47 49
48 val cache = ref LruCache.cache 50 val cache = ref LruCache.cache
805 807
806 val expOfSubexp = 808 val expOfSubexp =
807 fn Pure f => f () 809 fn Pure f => f ()
808 | Impure e => e 810 | Impure e => e
809 811
812 (* TODO: pick a number. *)
813 val sizeWorthCaching = 5
814
810 fun makeCache (env, exp', index) = 815 fun makeCache (env, exp', index) =
811 case typOfExp' env exp' of 816 case typOfExp' env exp' of
812 NONE => NONE 817 NONE => NONE
813 | SOME (TFun _, _) => NONE 818 | SOME (TFun _, _) => NONE
814 | SOME typ => 819 | SOME typ =>
815 if expSize (exp', dummyLoc) < 5 (* TODO: pick a number. *) 820 if expSize (exp', dummyLoc) < sizeWorthCaching
816 then NONE 821 then NONE
817 else case List.foldr (fn ((_, _), NONE) => NONE 822 else case List.foldr (fn ((_, _), NONE) => NONE
818 | ((n, typ), SOME args) => 823 | ((n, typ), SOME args) =>
819 case MonoFooify.urlify env ((ERel n, dummyLoc), typ) of 824 case MonoFooify.urlify env ((ERel n, dummyLoc), typ) of
820 NONE => NONE 825 NONE => NONE