summaryrefslogtreecommitdiff
path: root/src/gen_lib
diff options
context:
space:
mode:
authorThomas Bauereiss2018-05-11 12:12:16 +0100
committerThomas Bauereiss2018-05-11 12:12:16 +0100
commit968cd36942d7b80023618a13fb8e1f93db0cdd61 (patch)
treeb1aed696b8954e1f61c12d94298c308f46dba2af /src/gen_lib
parentff18bac6654a73cedf32a45ee406fe3e74ae3efd (diff)
Add Boolean short-circuiting to state monad
Diffstat (limited to 'src/gen_lib')
-rw-r--r--src/gen_lib/state.lem6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gen_lib/state.lem b/src/gen_lib/state.lem
index 6bc304a8..f69f59c1 100644
--- a/src/gen_lib/state.lem
+++ b/src/gen_lib/state.lem
@@ -28,6 +28,12 @@ end
declare {isabelle} termination_argument foreachS = automatic
+val and_boolS : forall 'rv 'e. monadS 'rv bool 'e -> monadS 'rv bool 'e -> monadS 'rv bool 'e
+let and_boolS l r = l >>$= (fun l -> if l then r else returnS false)
+
+val or_boolS : forall 'rv 'e. monadS 'rv bool 'e -> monadS 'rv bool 'e -> monadS 'rv bool 'e
+let or_boolS l r = l >>$= (fun l -> if l then returnS true else r)
+
val bool_of_bitU_fail : forall 'rv 'e. bitU -> monadS 'rv bool 'e
let bool_of_bitU_fail = function
| B0 -> returnS false