aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Eval.hs
diff options
context:
space:
mode:
authorMarvin Borner2023-03-12 00:03:51 +0100
committerMarvin Borner2023-03-12 00:03:51 +0100
commite789e11f8e478fe5987101424cf5c9c32cc6a29b (patch)
treef37f5a16a2337fe68d76ddd1982022b9b2a340a8 /src/Eval.hs
parentbc237aa79e64caf87ed9a51e41c284bbca51b176 (diff)
Added length&blc commands
Diffstat (limited to 'src/Eval.hs')
-rw-r--r--src/Eval.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Eval.hs b/src/Eval.hs
index 5ef743c..0478c02 100644
--- a/src/Eval.hs
+++ b/src/Eval.hs
@@ -266,6 +266,24 @@ evalCommand inp s@(EnvState env@(Environment envDefs) conf cache) = \case
putStrLn " Byte"
performGC
pure $ EnvState (Environment M.empty) conf (EnvCache M.empty)
+ Length e -> do
+ let (res, _) = evalExp e (Environment M.empty) `runState` env
+ case res of
+ Left err -> print err
+ Right e' -> do
+ red <- reduce e'
+ print $ length $ toBinary e'
+ print $ length $ toBinary red
+ pure s
+ Blc e -> do
+ let (res, _) = evalExp e (Environment M.empty) `runState` env
+ case res of
+ Left err -> print err
+ Right e' -> do
+ red <- reduce e'
+ putStrLn $ toBinary e'
+ putStrLn $ toBinary red
+ pure s
Time e -> do
start <- getTime Monotonic
let (res, _) = evalExp e (Environment M.empty) `runState` env