From 438a71dcb4090e7b83846fcd1de8be829a22c1aa Mon Sep 17 00:00:00 2001 From: martyall Date: Sun, 7 Jan 2024 22:32:40 -0800 Subject: [PATCH] Redundant constraints --- examples/Snarkl/Example/Basic.hs | 2 +- examples/Snarkl/Example/Games.hs | 30 +++++++++++------------------- examples/Snarkl/Example/Queue.hs | 6 ++---- snarkl.cabal | 2 ++ src/Snarkl/Common.hs | 2 +- src/Snarkl/Compile.hs | 14 +++++++------- src/Snarkl/Field.hs | 2 +- src/Snarkl/Interp.hs | 16 +++++++--------- src/Snarkl/Language.hs | 3 +-- src/Snarkl/Language/Core.hs | 6 +++++- src/Snarkl/Language/Expr.hs | 2 +- src/Snarkl/Language/LambdaExpr.hs | 4 ++-- src/Snarkl/Language/Syntax.hs | 2 +- src/Snarkl/Language/TExpr.hs | 2 +- src/Snarkl/Toplevel.hs | 5 +++-- tests/Test/ArkworksBridge.hs | 10 +++++++++- tests/Test/Snarkl/DataflowSpec.hs | 8 +++----- tests/Test/Snarkl/LambdaSpec.hs | 29 +++++++++++++---------------- tests/Test/Snarkl/Unit/Programs.hs | 5 +---- tests/Test/Snarkl/UnitSpec.hs | 16 +++++----------- tests/Test/UnionFindSpec.hs | 16 +++++++++++++--- 21 files changed, 90 insertions(+), 92 deletions(-) diff --git a/examples/Snarkl/Example/Basic.hs b/examples/Snarkl/Example/Basic.hs index 6572b3d..7a86fd1 100644 --- a/examples/Snarkl/Example/Basic.hs +++ b/examples/Snarkl/Example/Basic.hs @@ -73,4 +73,4 @@ test1 :: (GaloisField k) => State (Env k) (TExp 'TBool k) test1 = do b <- fresh_input z <- if return b then comp1 else comp2 - case_sum return (const $ return false) z \ No newline at end of file + case_sum return (const $ return false) z diff --git a/examples/Snarkl/Example/Games.hs b/examples/Snarkl/Example/Games.hs index e152e2c..0d0bf4e 100644 --- a/examples/Snarkl/Example/Games.hs +++ b/examples/Snarkl/Example/Games.hs @@ -6,9 +6,9 @@ module Snarkl.Example.Games where -import Data.Field.Galois (GaloisField, Prime) +import Data.Field.Galois (GaloisField) +import Data.Kind (Type) import Data.Typeable -import GHC.TypeLits (KnownNat, Nat) import Snarkl.Errors import Snarkl.Field (F_BN128) import Snarkl.Language.Syntax @@ -38,7 +38,7 @@ data ISO (t :: Ty) (s :: Ty) k = Iso from :: TExp s k -> Comp t k } -data Game :: Ty -> * -> * where +data Game :: Ty -> Type -> Type where Single :: forall (s :: Ty) (t :: Ty) k. ( Typeable s, @@ -108,8 +108,7 @@ sum_game :: Zippable t1 k, Zippable t2 k, Derive t1 k, - Derive t2 k, - GaloisField k + Derive t2 k ) => Game t1 k -> Game t2 k -> @@ -133,9 +132,7 @@ t2 :: F_BN128 t2 = comp_interp basic_test [1, 23, 88] -- 88 (+>) :: - ( Typeable t, - Typeable s, - Zippable t k, + ( Typeable s, Zippable s k ) => Game t k -> @@ -151,8 +148,7 @@ prodI :: ( Typeable a, Typeable b, Typeable c, - Typeable d, - GaloisField k + Typeable d ) => ISO a b k -> ISO c d k -> @@ -174,13 +170,12 @@ prodI (Iso f g) (Iso f' g') = pair y1 y2 ) -seqI :: (Typeable b) => ISO a b p -> ISO b c p -> ISO a c p +seqI :: ISO a b p -> ISO b c p -> ISO a c p seqI (Iso f g) (Iso f' g') = Iso (\a -> f a >>= f') (\c -> g' c >>= g) prodLInputI :: ( Typeable a, - Typeable b, - GaloisField k + Typeable b ) => ISO ('TProd a b) b k prodLInputI = @@ -200,8 +195,7 @@ prodLSumI :: Zippable c k, Derive a k, Derive b k, - Derive c k, - GaloisField k + Derive c k ) => ISO ('TProd ('TSum b c) a) ('TSum ('TProd b a) ('TProd c a)) k prodLSumI = @@ -301,8 +295,7 @@ instance (GaloisField k) => Gameable 'TUnit k where mkGame = unit_game instance - ( Typeable a, - Typeable b, + ( Typeable b, Zippable a k, Zippable b k, Derive a k, @@ -323,8 +316,7 @@ instance Derive a k, Derive b k, Gameable a k, - Gameable b k, - GaloisField k + Gameable b k ) => Gameable ('TSum a b) k where diff --git a/examples/Snarkl/Example/Queue.hs b/examples/Snarkl/Example/Queue.hs index b306692..ed06e12 100644 --- a/examples/Snarkl/Example/Queue.hs +++ b/examples/Snarkl/Example/Queue.hs @@ -2,10 +2,8 @@ module Snarkl.Example.Queue where -import Data.Field.Galois (GaloisField, Prime) +import Data.Field.Galois (GaloisField) import Data.Typeable -import GHC.TypeLits (KnownNat) -import Snarkl.Compile import Snarkl.Example.List import Snarkl.Example.Stack import Snarkl.Language.Syntax @@ -36,7 +34,7 @@ empty_queue = do pair l r enqueue :: - (Zippable a k, Derive a k, Typeable a, GaloisField k) => + (Typeable a, GaloisField k) => TExp a k -> Queue a k -> Comp (TQueue a) k diff --git a/snarkl.cabal b/snarkl.cabal index 183b982..8a7091c 100644 --- a/snarkl.cabal +++ b/snarkl.cabal @@ -141,6 +141,8 @@ test-suite spec , process >=1.2 , QuickCheck , snarkl >=0.1.0.0 + ghc-options: + -Wredundant-constraints benchmark criterion type: exitcode-stdio-1.0 diff --git a/src/Snarkl/Common.hs b/src/Snarkl/Common.hs index 374e523..953d841 100644 --- a/src/Snarkl/Common.hs +++ b/src/Snarkl/Common.hs @@ -67,4 +67,4 @@ isAssoc op = case op of Or -> True XOr -> True Eq -> True - BEq -> True \ No newline at end of file + BEq -> True diff --git a/src/Snarkl/Compile.hs b/src/Snarkl/Compile.hs index 124eca4..d11957a 100644 --- a/src/Snarkl/Compile.hs +++ b/src/Snarkl/Compile.hs @@ -249,19 +249,19 @@ encode_binop op (x, y, z) = go op add_constraint $ CMult (1, y) (1, z) (1, Just x) -encode_linear :: (GaloisField a) => Var -> [Either (Var, a) a] -> State (CEnv a) () +encode_linear :: (GaloisField k) => Var -> [Either (Var, k) k] -> State (CEnv k) () encode_linear out xs = let c = foldl (flip (+)) 0 $ map (fromRight 0) xs in add_constraint $ cadd c $ (out, -1) : remove_consts xs where - remove_consts :: [Either (Var, a) a] -> [(Var, a)] + remove_consts :: [Either (Var, k) k] -> [(Var, k)] remove_consts [] = [] remove_consts (Left p : l) = p : remove_consts l remove_consts (Right _ : l) = remove_consts l -cs_of_exp :: (GaloisField a) => Var -> Core.Exp a -> State (CEnv a) () +cs_of_exp :: (GaloisField k) => Var -> Core.Exp k -> State (CEnv k) () cs_of_exp out e = case e of Core.EVar x -> ensure_equal (out, view _Var x) @@ -287,7 +287,7 @@ cs_of_exp out e = case e of -- We special-case linear combinations in this way to avoid having -- to introduce new multiplication gates for multiplication by -- constant scalars. - let go_linear :: (GaloisField a) => [Core.Exp a] -> State (CEnv a) [Either (Var, a) a] + let go_linear :: (GaloisField k) => [Core.Exp k] -> State (CEnv k) [Either (Var, k) k] go_linear [] = return [] go_linear (Core.EBinop Mult [Core.EVar x, Core.EVal coeff] : es') = do @@ -338,7 +338,7 @@ cs_of_exp out e = case e of rev_pol (Left (x, c) : ls) = Left (x, -c) : rev_pol ls rev_pol (Right c : ls) = Right (-c) : rev_pol ls - go_other :: (GaloisField a) => [Core.Exp a] -> State (CEnv a) [Var] + go_other :: (GaloisField k) => [Core.Exp k] -> State (CEnv k) [Var] go_other [] = return [] go_other (Core.EVar x : es') = do @@ -457,10 +457,10 @@ data TExpPkg ty k = TExpPkg } deriving (Show) -instance (Typeable ty) => Pretty (TExpPkg ty k) where +instance Pretty (TExpPkg ty k) where pretty (TExpPkg _ _ e) = pretty e -deriving instance (Eq (TExp ty k)) => Eq (TExpPkg ty k) +deriving instance Eq (TExpPkg ty k) -- | Desugar a 'Comp'utation to a pair of: -- the total number of vars, diff --git a/src/Snarkl/Field.hs b/src/Snarkl/Field.hs index f8f6e9f..1f193af 100644 --- a/src/Snarkl/Field.hs +++ b/src/Snarkl/Field.hs @@ -6,4 +6,4 @@ import Data.Field.Galois (Prime) type P_BN128 = 21888242871839275222246405745257275088548364400416034343698204186575808495617 -type F_BN128 = Prime P_BN128 \ No newline at end of file +type F_BN128 = Prime P_BN128 diff --git a/src/Snarkl/Interp.hs b/src/Snarkl/Interp.hs index ba269e7..4d66dd5 100644 --- a/src/Snarkl/Interp.hs +++ b/src/Snarkl/Interp.hs @@ -4,7 +4,6 @@ module Snarkl.Interp where import Control.Monad (ap, foldM) -import Data.Data (Typeable) import Data.Field.Galois (GaloisField) import Data.Foldable (traverse_) import Data.Map (Map) @@ -77,20 +76,19 @@ boolOfField v = ) interpTExp :: - ( GaloisField a, - Typeable ty + ( GaloisField k ) => - TExp ty a -> - InterpM a (Maybe a) + TExp ty k -> + InterpM k (Maybe k) interpTExp e = do let _exp = compileTExpToProgram e interpProg _exp interp :: - (GaloisField a, Typeable ty) => - Map Variable a -> - TExp ty a -> - Either ErrMsg (Env a, Maybe a) + (GaloisField k) => + Map Variable k -> + TExp ty k -> + Either ErrMsg (Env k, Maybe k) interp rho e = runInterpM (interpTExp e) $ Map.map Just rho interpProg :: diff --git a/src/Snarkl/Language.hs b/src/Snarkl/Language.hs index 886eee7..ca413c9 100644 --- a/src/Snarkl/Language.hs +++ b/src/Snarkl/Language.hs @@ -85,7 +85,6 @@ module Snarkl.Language ) where -import Data.Data (Typeable) import Data.Field.Galois (GaloisField) import Snarkl.Language.Core ( Assignment (..), @@ -166,7 +165,7 @@ import Snarkl.Language.TExpr (TExp, booleanVarsOfTexp, tExpToLambdaExp) import Snarkl.Language.Type import Prelude (Either (..), error, ($), (.), (<>)) -compileTExpToProgram :: (GaloisField a, Typeable ty) => TExp ty a -> Program a +compileTExpToProgram :: (GaloisField k) => TExp ty k -> Program k compileTExpToProgram te = let eprog = mkProgram . expOfLambdaExp . tExpToLambdaExp $ te in case eprog of diff --git a/src/Snarkl/Language/Core.hs b/src/Snarkl/Language/Core.hs index 4a75db2..9dffa2e 100644 --- a/src/Snarkl/Language/Core.hs +++ b/src/Snarkl/Language/Core.hs @@ -13,9 +13,13 @@ data Exp :: Type -> Type where EVal :: (GaloisField k) => k -> Exp k EUnop :: UnOp -> Exp k -> Exp k EBinop :: Op -> [Exp k] -> Exp k - EIf :: Exp k -> Exp a -> Exp k -> Exp k + EIf :: Exp k -> Exp k -> Exp k -> Exp k EUnit :: Exp k +deriving instance Eq (Exp k) + +deriving instance Show (Exp k) + data Assignment a = Assignment Variable (Exp a) data Program :: Type -> Type where diff --git a/src/Snarkl/Language/Expr.hs b/src/Snarkl/Language/Expr.hs index 4480513..287e34e 100644 --- a/src/Snarkl/Language/Expr.hs +++ b/src/Snarkl/Language/Expr.hs @@ -152,7 +152,7 @@ mkProgram _exp = do let (eexpr, assignments) = runState (runExceptT $ go es) mempty Core.Program assignments <$> eexpr where - go :: (Show k) => Seq (Exp k) -> ExceptT String (State (Seq (Core.Assignment k))) (Core.Exp k) + go :: Seq (Exp k) -> ExceptT String (State (Seq (Core.Assignment k))) (Core.Exp k) go = \case Empty -> throwError "mkProgram: empty sequence" e :<| Empty -> hoistEither $ mkExpression e diff --git a/src/Snarkl/Language/LambdaExpr.hs b/src/Snarkl/Language/LambdaExpr.hs index 897383f..d1b79cf 100644 --- a/src/Snarkl/Language/LambdaExpr.hs +++ b/src/Snarkl/Language/LambdaExpr.hs @@ -38,7 +38,7 @@ deriving instance Show (Exp k) deriving instance Eq (Exp k) -betaNormalize :: Exp a -> Exp a +betaNormalize :: Exp k -> Exp k betaNormalize = \case EVar x -> EVar x EVal v -> EVal v @@ -55,7 +55,7 @@ betaNormalize = \case EUnit -> EUnit where -- substitute x e1 e2 = e2 [x := e1 ] - substitute :: (Variable, Exp a) -> Exp a -> Exp a + substitute :: (Variable, Exp k) -> Exp k -> Exp k substitute (var, e1) = \case e@(EVar var') -> if var == var' then e1 else e e@(EVal _) -> e diff --git a/src/Snarkl/Language/Syntax.hs b/src/Snarkl/Language/Syntax.hs index 7cae059..1f5e419 100644 --- a/src/Snarkl/Language/Syntax.hs +++ b/src/Snarkl/Language/Syntax.hs @@ -768,4 +768,4 @@ uncurry f p = do return $ TEApp g y apply :: (Typeable a, Typeable b) => TExp ('TFun a b) k -> TExp a k -> Comp b k -apply f x = return $ TEApp f x +apply f x = return $ TEApp f x \ No newline at end of file diff --git a/src/Snarkl/Language/TExpr.hs b/src/Snarkl/Language/TExpr.hs index 7d97d81..36c294e 100644 --- a/src/Snarkl/Language/TExpr.hs +++ b/src/Snarkl/Language/TExpr.hs @@ -217,4 +217,4 @@ lastSeq :: TExp ty a lastSeq te = case te of TESeq _ te2 -> lastSeq te2 - _ -> te \ No newline at end of file + _ -> te diff --git a/src/Snarkl/Toplevel.hs b/src/Snarkl/Toplevel.hs index 99df998..4f24429 100644 --- a/src/Snarkl/Toplevel.hs +++ b/src/Snarkl/Toplevel.hs @@ -41,7 +41,8 @@ import Prelude -- | Using the executable semantics for the 'TExp' language, execute -- the computation on the provided inputs, returning the 'k' result. comp_interp :: - (Typeable ty, GaloisField k) => + forall ty k. + (GaloisField k) => Comp ty k -> [k] -> k @@ -64,7 +65,7 @@ data Result k = Result } deriving (Show) -instance Pretty (Result k) where +instance (Pretty k) => Pretty (Result k) where pretty (Result sat vars constraints result _ _) = mconcat $ intercalate diff --git a/tests/Test/ArkworksBridge.hs b/tests/Test/ArkworksBridge.hs index e1e4703..f847a9b 100644 --- a/tests/Test/ArkworksBridge.hs +++ b/tests/Test/ArkworksBridge.hs @@ -4,8 +4,16 @@ import qualified Data.ByteString.Lazy as LBS import Data.Field.Galois (GaloisField, PrimeField) import Data.Typeable (Typeable) import Snarkl.Backend.R1CS + ( mkInputsFilePath, + mkR1CSFilePath, + mkWitnessFilePath, + serializeInputsAsJson, + serializeR1CSAsJson, + serializeWitnessAsJson, + wit_of_r1cs, + ) import Snarkl.Compile (SimplParam, compileCompToR1CS) -import Snarkl.Language (Comp) +import Snarkl.Language.SyntaxMonad (Comp) import qualified System.Exit as GHC import System.Process (createProcess, shell, waitForProcess) diff --git a/tests/Test/Snarkl/DataflowSpec.hs b/tests/Test/Snarkl/DataflowSpec.hs index e4a5384..5dc2d1b 100644 --- a/tests/Test/Snarkl/DataflowSpec.hs +++ b/tests/Test/Snarkl/DataflowSpec.hs @@ -2,9 +2,7 @@ module Test.Snarkl.DataflowSpec where -import Data.Field.Galois (GaloisField, Prime, PrimeField, toP) -import qualified Data.IntMap as IntMap -import qualified Data.Map as Map +import Data.Field.Galois (Prime, toP) import qualified Data.Set as Set import GHC.TypeLits (KnownNat) import Snarkl.Common (Var (Var)) @@ -30,8 +28,8 @@ constraint2 :: (KnownNat p) => Constraint (Prime p) constraint2 = CMult (toP 2, Var 1) (toP 3, Var 2) (toP 4, Just $ Var 3) -- NOTE: notice 4 doesn't count as a variable here, WHY? -constraint3 :: (GaloisField k) => Constraint k -constraint3 = CMagic (Var 4) [Var 2, Var 3] $ \vars -> return True +constraint3 :: Constraint k +constraint3 = CMagic (Var 4) [Var 2, Var 3] $ \_ -> return True -- 4 is independent from 1,2,3 constraint4 :: (KnownNat p) => Constraint (Prime p) diff --git a/tests/Test/Snarkl/LambdaSpec.hs b/tests/Test/Snarkl/LambdaSpec.hs index 5feedb8..08f1f5d 100644 --- a/tests/Test/Snarkl/LambdaSpec.hs +++ b/tests/Test/Snarkl/LambdaSpec.hs @@ -5,12 +5,7 @@ {-# HLINT ignore "Redundant uncurry" #-} module Test.Snarkl.LambdaSpec where -import Data.Field.Galois (GaloisField, Prime) -import qualified Data.Map as Map -import GHC.TypeLits (KnownNat) -import Snarkl.Field -import Snarkl.Interp (interp) -import Snarkl.Language (TExp, Ty (TField, TFun, TProd)) +import Snarkl.Field (F_BN128) import Snarkl.Language.Syntax ( apply, curry, @@ -21,27 +16,29 @@ import Snarkl.Language.Syntax (+), ) import qualified Snarkl.Language.SyntaxMonad as SM +import Snarkl.Language.TExpr (TExp) +import Snarkl.Language.Type (Ty (TField, TFun, TProd)) import Snarkl.Toplevel (comp_interp) -import Test.Hspec (Spec, describe, it, shouldBe) +import Test.Hspec (Spec, describe, it) import Test.QuickCheck (Testable (property)) -import Prelude hiding (apply, curry, return, uncurry, (*), (+)) +import Prelude hiding (curry, return, uncurry, (*), (+)) spec :: Spec spec = do describe "Snarkl.Lambda" $ do describe "curry/uncurry identities for simply operations" $ do it "curry . uncurry == id" $ do - let f :: (GaloisField k) => TExp 'TField k -> SM.Comp ('TFun 'TField 'TField) k + let f :: TExp 'TField k -> SM.Comp ('TFun 'TField 'TField) k f x = lambda $ \y -> SM.return (x + y) - g :: (GaloisField k) => TExp 'TField k -> SM.Comp ('TFun 'TField 'TField) k + g :: TExp 'TField k -> SM.Comp ('TFun 'TField 'TField) k g = curry (uncurry f) - prog1 :: (GaloisField k) => SM.Comp 'TField k + prog1 :: SM.Comp 'TField k prog1 = SM.fresh_input SM.>>= \a -> SM.fresh_input SM.>>= \b -> f a SM.>>= \k -> apply k b - prog2 :: (GaloisField k) => SM.Comp 'TField k + prog2 :: SM.Comp 'TField k prog2 = SM.fresh_input SM.>>= \a -> SM.fresh_input SM.>>= \b -> @@ -51,21 +48,21 @@ spec = do comp_interp @_ @F_BN128 prog1 [a, b] == comp_interp prog2 [a, b] it "uncurry . curry == id" $ do - let f :: (GaloisField k) => TExp ('TProd 'TField 'TField) k -> SM.Comp 'TField k + let f :: TExp ('TProd 'TField 'TField) k -> SM.Comp 'TField k f p = SM.fst_pair p SM.>>= \x -> SM.snd_pair p SM.>>= \y -> SM.return (x * y) - g :: (GaloisField k) => TExp ('TProd 'TField 'TField) k -> SM.Comp 'TField k + g :: TExp ('TProd 'TField 'TField) k -> SM.Comp 'TField k g = uncurry (curry f) - prog1 :: (GaloisField k) => SM.Comp 'TField k + prog1 :: SM.Comp 'TField k prog1 = SM.fresh_input SM.>>= \a -> SM.fresh_input SM.>>= \b -> pair a b SM.>>= \p -> f p - prog2 :: (GaloisField k) => SM.Comp 'TField k + prog2 :: SM.Comp 'TField k prog2 = SM.fresh_input SM.>>= \a -> SM.fresh_input SM.>>= \b -> diff --git a/tests/Test/Snarkl/Unit/Programs.hs b/tests/Test/Snarkl/Unit/Programs.hs index 0202751..df1d889 100644 --- a/tests/Test/Snarkl/Unit/Programs.hs +++ b/tests/Test/Snarkl/Unit/Programs.hs @@ -8,14 +8,11 @@ module Test.Snarkl.Unit.Programs where -import Data.Field.Galois (GaloisField, Prime) -import Snarkl.Compile -import Snarkl.Example.Keccak import Snarkl.Example.Lam import Snarkl.Example.List import Snarkl.Example.Peano import Snarkl.Example.Tree -import Snarkl.Field (F_BN128, P_BN128) +import Snarkl.Field (F_BN128) import Snarkl.Language.Syntax import Snarkl.Language.SyntaxMonad import Snarkl.Language.TExpr diff --git a/tests/Test/Snarkl/UnitSpec.hs b/tests/Test/Snarkl/UnitSpec.hs index 04c9800..6e356ac 100644 --- a/tests/Test/Snarkl/UnitSpec.hs +++ b/tests/Test/Snarkl/UnitSpec.hs @@ -7,22 +7,16 @@ import Data.Field.Galois (PrimeField) import Data.Typeable (Typeable) import Snarkl.Compile import Snarkl.Example.Keccak -import Snarkl.Example.Lam -import Snarkl.Example.List -import Snarkl.Example.Peano -import Snarkl.Example.Tree import Snarkl.Field -import Snarkl.Language (Comp) -import Snarkl.Language.Syntax hiding (negate) +import Snarkl.Language (Comp, Ty (..)) import Snarkl.Toplevel (Result (result_result), execute) import System.Exit (ExitCode (..)) import Test.ArkworksBridge (CMD (RunR1CS), runCMD) -import Test.Hspec (Spec, describe, it, shouldBe, shouldReturn) +import Test.Hspec (Spec, describe, it, shouldReturn) import Test.Snarkl.Unit.Programs -import Text.PrettyPrint.Leijen.Text (Pretty) import Prelude -test_comp :: (Typeable ty, Pretty k, PrimeField k) => SimplParam -> Comp ty k -> [k] -> IO (Either ExitCode k) +test_comp :: forall ty k. (Typeable ty, PrimeField k) => SimplParam -> Comp ty k -> [k] -> IO (Either ExitCode k) test_comp simpl mf args = do exit_code <- runCMD $ RunR1CS "./scripts" "hspec" simpl mf args @@ -72,7 +66,7 @@ spec = do it "8-1" $ test_comp @_ @F_BN128 Simplify prog8 [] `shouldReturn` Right 29 describe "unused inputs" $ do - it "11-1" $ test_comp @_ @F_BN128 Simplify prog11 [1, 1] `shouldReturn` Right 1 + it "11-1" $ test_comp @'TField @F_BN128 Simplify prog11 [1, 1] `shouldReturn` Right 1 describe "multiplicative identity" $ do it "13-1" $ test_comp @_ @F_BN128 Simplify prog13 [1] `shouldReturn` Right 1 @@ -147,7 +141,7 @@ spec = do it "8-1" $ test_comp @_ @F_BN128 Simplify prog8 [] `shouldReturn` Right 29 describe "unused inputs" $ do - it "11-1" $ test_comp @_ @F_BN128 Simplify prog11 [1, 1] `shouldReturn` Right 1 + it "11-1" $ test_comp @'TField @F_BN128 Simplify prog11 [1, 1] `shouldReturn` Right 1 describe "multiplicative identity" $ do it "13-1" $ test_comp @_ @F_BN128 Simplify prog13 [1] `shouldReturn` Right 1 diff --git a/tests/Test/UnionFindSpec.hs b/tests/Test/UnionFindSpec.hs index a932eb9..ee9774a 100644 --- a/tests/Test/UnionFindSpec.hs +++ b/tests/Test/UnionFindSpec.hs @@ -6,11 +6,21 @@ module Test.UnionFindSpec where -import Snarkl.Common +import Snarkl.Common (Var (..)) import Snarkl.Constraint.UnionFind -import Snarkl.Errors -import Test.Hspec + ( UnionFind, + empty, + insert, + root, + unite, + ) +import Test.Hspec (Spec, describe, it, shouldBe) import Test.QuickCheck + ( Arbitrary (arbitrary), + Testable (property), + forAll, + suchThat, + ) spec :: Spec spec = do