Skip to content

Commit 6c97e43

Browse files
authored
rewrites knowledge and primus monads (#1361)
* reimplements the knowledge monad * uses the parallel binding operators in the theory merging operators * publishes `zero` and `succ` in the Monad.State.Multi.Id interface * rewrites the Primus Monad * a couple of microoptimzations (with no observable benefits) * removes the upper bound fro bitstring in opam/opam * reverts an accidental change to the opam/opam file
1 parent 97cc1a3 commit 6c97e43

File tree

5 files changed

+321
-183
lines changed

5 files changed

+321
-183
lines changed

lib/bap_core_theory/bap_core_theory_manager.ml

+9-18
Original file line numberDiff line numberDiff line change
@@ -80,52 +80,43 @@ let declare
8080
}
8181

8282
let (++) x y =
83-
x >>= fun x ->
84-
y >>| fun y ->
83+
let+ x = x and+ y = y in
8584
Value.merge x y
8685
[@@inline]
8786

87+
8888
let join1 p q x =
89-
x >>= fun x ->
89+
let* x = x in
9090
p !!x ++ q !!x
9191
[@@inline]
9292

9393
let join1s p q s x =
94-
x >>= fun x ->
94+
let* x = x in
9595
p s !!x ++ q s !!x
9696
[@@inline]
9797

9898
let join2 p q x y =
99-
x >>= fun x ->
100-
y >>= fun y ->
99+
let* x = x and+ y = y in
101100
p !!x !!y ++ q !!x !!y
102101
[@@inline]
103102

104103
let join2s p q s x y =
105-
x >>= fun x ->
106-
y >>= fun y ->
104+
let* x = x and+ y = y in
107105
p s !!x !!y ++ q s !!x !!y
108106
[@@inline]
109107

110108
let join3 p q x y z =
111-
x >>= fun x ->
112-
y >>= fun y ->
113-
z >>= fun z ->
109+
let* x = x and* y = y and* z = z in
114110
p !!x !!y !!z ++ q !!x !!y !!z
115111
[@@inline]
116112

117113
let join3s p q s x y z =
118-
x >>= fun x ->
119-
y >>= fun y ->
120-
z >>= fun z ->
114+
let* x = x and* y = y and* z = z in
121115
p s !!x !!y !!z ++ q s !!x !!y !!z
122116
[@@inline]
123117

124118
let join4 p q r x y z =
125-
r >>= fun r ->
126-
x >>= fun x ->
127-
y >>= fun y ->
128-
z >>= fun z ->
119+
let* r = r and* x = x and* y = y and* z = z in
129120
p !!r !!x !!y !!z ++ q !!r !!x !!y !!z
130121
[@@inline]
131122

0 commit comments

Comments
 (0)