]> gitweb.factorcode.org Git - factor.git/blob - basis/fixups/fixups.factor
fixups: integrate with restarts
[factor.git] / basis / fixups / fixups.factor
1 ! Copyright (C) 2021 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs continuations formatting kernel
4 sequences ui.tools.debugger vocabs vocabs.parser ;
5 IN: fixups
6
7 CONSTANT: vocab-renames {
8     { "math.intervals" { "intervals" "0.99" } }
9     { "math.ranges" { "ranges" "0.99" } }
10     { "asdfasdf" { "asdfasdf2" "0.99" } }
11 }
12
13 CONSTANT: word-renames {
14     { "lines" { "io:read-lines" "0.99" } }
15     { "lines" { "splitting:split-lines" "0.99" } }
16     { "words" { "splitting:split-words" "0.99" } }
17     { "contents" { "io:read-contents" "0.99" } }
18     { "exists?" { "io.files:file-exists?" "0.99" } }
19     { "string-lines" { "splitting:split-lines" "0.99" } }
20     { "split-lines" { "documents.private:?split-lines" "0.99" } }
21     { "[-inf,a)" { "math.intervals:[-inf,b)" "0.99" } }
22     { "[-inf,a]" { "math.intervals:[-inf,b]" "0.99" } }
23     { "(a,b)" { "math.ranges:(a..b)" "0.99" } }
24     { "(a,b]" { "math.ranges:(a..b]" "0.99" } }
25     { "[a,b)" { "math.ranges:[a..b)" "0.99" } }
26     { "[a,b]" { "math.ranges:[a..b]" "0.99" } }
27     { "assoc-merge" { "assocs.extras:assoc-collect" "0.99" } }
28     { "assoc-merge!" { "assocs.extras:assoc-collect!" "0.99" } }
29     { "peek-from" { "modern.html:peek1-from" "0.99" } }
30     { "in?" { "interval-sets:interval-in?" "0.99" } }
31     { "substitute" { "regexp.classes:(substitute)" "0.99" } }
32     { "combine" { "sets:union-all" "0.99" } }
33     { "refine" { "sets:intersect-all" "0.99" } }
34     { "read-json-objects" { "json.reader:read-json" "0.99" } }
35     { "iota" { "sequences:<iota>" ".98" } }
36 }
37
38 : compute-assoc-fixups ( continuation name assoc -- seq )
39     swap '[ drop _ = ] assoc-filter [
40         drop { }
41     ] [
42         swap '[
43             first2 dupd first2 "Fixup: %s renamed to %s in Factor %s" sprintf
44             swap drop no-op-action
45             _ <restart>
46         ] map
47     ] if-empty ;
48
49 GENERIC: compute-fixups ( continuation error -- seq )
50
51 M: object compute-fixups
52     [ error>> compute-fixups ] [ 3drop { } ] recover ;
53
54 M: f compute-fixups 2drop { } ;
55
56 M: no-vocab compute-fixups
57     name>> vocab-renames compute-assoc-fixups ;
58
59 M: no-word-error compute-fixups
60     name>> word-renames compute-assoc-fixups ;