You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider this interpreter for logical expressions:
data Val
= Zero
| One
data Ast
= Val Val
| Not Ast
| Or Ast Ast
| And Ast Ast
eval :: Ast -> Val
eval x = case x of
Val b -> b
Not e ->
case eval e of
One -> Zero
Zero -> One
Or e1 e2 ->
case eval e1 of
One -> One
Zero -> eval e2
And e1 e2 ->
case eval e1 of
One -> eval e2
Zero -> Zero
gibbon_main =
let
_ = printPacked (eval (Val Zero)) -- works
_ = printPacked (eval (Val One)) -- works
_ = printPacked (eval (Not (Val One))) -- hangs
_ = printPacked (eval (And (Val One) (Val One))) -- hangs
_ = printPacked (eval (Or (Val One) (Val One))) -- hangs
in ()
All expressions which contain a node with an operator will cause the evaluator to hang. Tested on issue_191.
The text was updated successfully, but these errors were encountered:
data Ast
= Val Bool
| Not Ast
| Or Ast Ast
| And Ast Ast
eval :: Ast -> Bool
eval x = case x of
Val b -> b
Not e -> if eval e then False else True
Or e1 e2 -> if eval e1 then True else eval e2
And e1 e2 -> if eval e1 then eval e2 else False
simplify :: Ast -> Ast
simplify x = Val (eval x)
gibbon_main =
let
_ = printPacked (simplify (Val False))
_ = printPacked (simplify (Val True))
_ = printPacked (simplify (Not (Val True)))
_ = printPacked (simplify (And (Val True) (Val True)))
_ = printPacked (simplify (Or (Val True) (Val True)))
in ()
Consider this interpreter for logical expressions:
All expressions which contain a node with an operator will cause the evaluator to hang. Tested on
issue_191
.The text was updated successfully, but these errors were encountered: