aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2019-06-02 12:54:15 +0100
committerYann Herklotz <git@yannherklotz.com>2019-06-02 12:54:15 +0100
commit43e074229c4ea859e66035c716d8bb4fcd037c90 (patch)
tree7edd371e7e652621ffce09a0e7fffb199f6e28b0
parentea15b7dfda1cf087a2810168543352d9fe1cbef4 (diff)
downloadverismith-43e074229c4ea859e66035c716d8bb4fcd037c90.tar.gz
verismith-43e074229c4ea859e66035c716d8bb4fcd037c90.zip
Add check for quicker reduction
-rw-r--r--src/VeriFuzz/Reduce.hs36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/VeriFuzz/Reduce.hs b/src/VeriFuzz/Reduce.hs
index 2f44c07..2a8b489 100644
--- a/src/VeriFuzz/Reduce.hs
+++ b/src/VeriFuzz/Reduce.hs
@@ -514,24 +514,26 @@ reduce_ title repl bot eval src = do
(src ^.. infoSrc . _Wrapped . traverse . modItems . traverse)
)
<> ")"
- case repl src of
- Single s -> do
- red <- eval s
- if red
- then if cond s then recReduction s else return s
- else return src
- Dual l r -> do
- red <- eval l
- if red
- then if cond l then recReduction l else return l
- else do
- red' <- eval r
- if red'
- then if cond r then recReduction r else return r
- else return src
- None -> return src
+ if bot src
+ then return src
+ else case repl src of
+ Single s -> do
+ red <- eval s
+ if red
+ then if cond s then recReduction s else return s
+ else return src
+ Dual l r -> do
+ red <- eval l
+ if red
+ then if cond l then recReduction l else return l
+ else do
+ red' <- eval r
+ if red'
+ then if cond r then recReduction r else return r
+ else return src
+ None -> return src
where
- cond s = s /= src && not (bot s)
+ cond s = s /= src
recReduction = reduce_ title repl bot eval
-- | Reduce an input to a minimal representation. It follows the reduction