Skip to content

Commit

Permalink
better handling of lambdas. Fixes #723
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Aug 22, 2024
1 parent f23f2c4 commit e79906e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Data/SBV/Utils/SExpr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,16 @@ parseSetLambda funExpr = case funExpr of
-- be flexible, this is certainly not a full fledged parser. But hopefully it'll
-- cover everything z3 will throw at it.
parseLambdaExpression :: SExpr -> Maybe ([([SExpr], SExpr)], SExpr)
parseLambdaExpression funExpr = case funExpr of
parseLambdaExpression funExpr = case squashLambdas funExpr of
EApp [ECon "lambda", EApp params, body] -> mapM getParam params >>= flip lambda body >>= chainAssigns
_ -> Nothing
where getParam (EApp [ECon v, ECon ty]) = Just (v, ty == "Bool")
where -- convert (lambda p1 (lambda p2 body)) to (lambda (p1 ++ p2) body)
squashLambdas (EApp [ECon "lambda", EApp p1
, EApp [ECon "lambda", EApp p2, body]])
= squashLambdas $ EApp [ECon "lambda", EApp (p1 ++ p2), body]
squashLambdas other = other

getParam (EApp [ECon v, ECon ty]) = Just (v, ty == "Bool")
getParam (EApp [ECon v, _ ]) = Just (v, False)
getParam _ = Nothing

Expand Down

0 comments on commit e79906e

Please sign in to comment.