on master help sign in
Made everything faster
commitc09738facb9d286dc1153696c573a4cdf8462b4d authoriko <mail@iko.soy> dateMon 14 Aug 2023, 17:01 (3 years ago) parent0ea69da
3 files changed+37−16
src/Nock.hs+35−14 tests/golden/dec.hoon+1−1 tests/golden/dec.nock+1−1
src/Nock.hs+35−14
@@ -31,6 +31,24 @@ sig = atom 0
3131one :: Noun
3232one = atom 1
3333
34+two :: Noun
35+two = atom 2
36+
37+three :: Noun
38+three = atom 3
39+
40+four :: Noun
41+four = atom 4
42+
43+twoThree :: Noun
44+twoThree = cell two three
45+
46+sigOne :: Noun
47+sigOne = cell sig one
48+
49+sigThree :: Noun
50+sigThree = cell sig three
51+
3452annotation :: RawNoun ann -> ann
3553annotation (Atom _ ann) = ann
3654annotation (Cell _ _ ann) = ann
@@ -90,25 +108,28 @@ hax ~(Cell ~(Atom n _) ~(Cell b c _) _) =
90108 _ -> hax (cell (atom a) (cell (cell (fas (cell (atom $ a + a) c)) b) c))
91109
92110tar :: Noun -> Noun
93−tar ~(Cell a ~(Cell b c _) _) = case b of
94− Cell x y _ -> cell (tar (cell a (cell x y))) (tar (cell a c))
111+tar ~(Cell subject x _) = tar' x subject
112+
113+tar' :: Noun -> Noun -> Noun
114+tar' ~(Cell b c _) subject = case b of
115+ Cell x y _ -> cell (tar' (cell x y) subject) (tar' c subject)
95116 Atom n _ -> case n of
96− 0 -> fas $ cell c a
117+ 0 -> fas $ cell c subject
97118 1 -> c
98− 3 -> wut $ tar $ cell a c
99− 4 -> lus $ tar $ cell a c
119+ 3 -> wut $ tar' c subject
120+ 4 -> lus $ tar' c subject
100121 _ -> case c of
101122 ~(Cell x y _) -> case n of
102− 2 -> tar $ cell (tar $ cell a x) (tar $ cell a y)
103− 5 -> tis $ cell (tar $ cell a x) (tar $ cell a y)
104− 7 -> tar $ cell (tar $ cell a x) y
105− 8 -> tar $ cell (cell (tar $ cell a x) a) y
106− 9 -> tar $ cell (tar $ cell a y) $ cell (atom 2) (cell (cell sig one) (cell sig x))
123+ 2 -> tar' (tar' y subject) (tar' x subject)
124+ 5 -> tis $ cell (tar' y subject) (tar' x subject)
125+ 7 -> tar' y (tar' x subject)
126+ 8 -> tar' y (cell (tar' x subject) subject)
127+ 9 -> tar' (cell two (cell sigOne (cell sig x))) (tar' y subject)
107128 6 -> case y of
108− ~(Cell c' d' _) -> tar $ cell a $ tar $ cell (cell c' d') $ cell sig $ tar $ cell (cell (atom 2) (atom 3)) $ cell sig $ tar $ cell a (cell (atom 4) (cell (atom 4) x))
129+ ~(Cell c' d' _) -> tar' (tar' (cell sig $ tar' (cell sig $ tar' (cell four (cell four x)) subject) twoThree) (cell c' d')) subject
109130 10 -> case x of
110− ~(Cell b' c' _) -> hax $ cell b' $ cell (tar (cell a c')) $ tar $ cell a y
131+ ~(Cell b' c' _) -> hax $ cell b' $ cell (tar' c' subject) $ tar' y subject
111132 11 -> case x of
112− Cell _ c' _ -> tar $ cell (cell (tar $ cell a c') (tar $ cell a y)) $ cell sig (atom 3)
113− Atom _ _ -> tar $ cell a y
133+ Cell _ c' _ -> tar' sigThree (cell (tar' c' subject) (tar' y subject))
134+ Atom _ _ -> tar' y subject
114135 u -> error $ show u
tests/golden/dec.hoon+1−1
@@ -14,4 +14,4 @@
1414$(b +(b))
1515--
1616
17−%- dec 8
17+%- dec 1.000.000
tests/golden/dec.nock+1−1
@@ -1 +1 @@
1−7
1+999999