update Haskell to handle the "new" (previously missing from upstream) unary operations

This commit is contained in:
Balazs Komuves 2025-03-15 13:50:56 +01:00
parent 87316bb87b
commit 4a8f564ba9
No known key found for this signature in database
GPG Key ID: F63B7AEF18435562
2 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,8 @@ data Graph = Graph
data UnoOp
= Neg -- ^ @= 0@
| Id -- ^ @= 1@
| Lnot -- ^ @= 2@
| Bnot -- ^ @= 3@
deriving (Eq,Enum,Bounded,Show)
data DuoOp

View File

@ -18,6 +18,8 @@ data PrimOp a
-- unary
= Neg a
| Id a
| Lnot a
| Bnot a
-- binary
| Mul a a
| Div a a
@ -49,6 +51,8 @@ evalPrimOp :: PrimOp F -> F
evalPrimOp prim = case prim of
Neg x -> neg x
Id x -> x
Lnot x -> fromBool (not (toBool x))
Bnot x -> toF (fieldMask .&. (negate (fromF x) - 1))
Mul x y -> mul x y
Div x y -> BN254.div x y
Add x y -> add x y