Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data UnOp f a where
- data BinOp f a where
- data Expr i f ty where
- EConst :: f -> Expr i f f
- EConstBool :: Bool -> Expr i f Bool
- EVar :: i -> Expr i f f
- EVarBool :: i -> Expr i f Bool
- EUnOp :: UnOp f ty -> Expr i f ty -> Expr i f ty
- EBinOp :: BinOp f ty -> Expr i f ty -> Expr i f ty -> Expr i f ty
- EIf :: Expr i f Bool -> Expr i f ty -> Expr i f ty -> Expr i f ty
- EEq :: Expr i f f -> Expr i f f -> Expr i f Bool
- type ExprM f a = State (ArithCircuit f, Int) a
- compile :: Num f => Expr Wire f ty -> ExprM f (Either Wire (AffineCircuit Wire f))
- emit :: Gate Wire f -> ExprM f ()
- imm :: ExprM f Wire
- addVar :: Either Wire (AffineCircuit Wire f) -> AffineCircuit Wire f
- addWire :: Num f => Either Wire (AffineCircuit Wire f) -> ExprM f Wire
- freshInput :: ExprM f Wire
- freshOutput :: ExprM f Wire
- rotateList :: Int -> [a] -> [a]
- runCircuitBuilder :: ExprM f a -> (a, ArithCircuit f)
- evalCircuitBuilder :: ExprM f a -> a
- execCircuitBuilder :: ExprM f a -> ArithCircuit f
- exprToArithCircuit :: Num f => Expr Int f ty -> Wire -> ExprM f ()
- evalExpr :: (Bits f, Num f) => (i -> vars -> Maybe f) -> Expr i f ty -> vars -> ty
- truncRotate :: Bits f => Int -> Int -> f -> f
Documentation
data Expr i f ty where Source #
Expression data type of (arithmetic) expressions over a field f
with variable names/indices coming from i
.
EConst :: f -> Expr i f f | |
EConstBool :: Bool -> Expr i f Bool | |
EVar :: i -> Expr i f f | |
EVarBool :: i -> Expr i f Bool | |
EUnOp :: UnOp f ty -> Expr i f ty -> Expr i f ty | |
EBinOp :: BinOp f ty -> Expr i f ty -> Expr i f ty -> Expr i f ty | |
EIf :: Expr i f Bool -> Expr i f ty -> Expr i f ty -> Expr i f ty | |
EEq :: Expr i f f -> Expr i f f -> Expr i f Bool |
addVar :: Either Wire (AffineCircuit Wire f) -> AffineCircuit Wire f Source #
Turn a wire into an affine circuit, or leave it be
addWire :: Num f => Either Wire (AffineCircuit Wire f) -> ExprM f Wire Source #
Turn an affine circuit into a wire, or leave it be
freshInput :: ExprM f Wire Source #
Fresh input variables
freshOutput :: ExprM f Wire Source #
Fresh output variables
rotateList :: Int -> [a] -> [a] Source #
Rotate a list to the right
runCircuitBuilder :: ExprM f a -> (a, ArithCircuit f) Source #
evalCircuitBuilder :: ExprM f a -> a Source #
execCircuitBuilder :: ExprM f a -> ArithCircuit f Source #
:: Num f | |
=> Expr Int f ty | expression to compile |
-> Wire | Wire to assign the output of the expression to |
-> ExprM f () |
Translate an arithmetic expression to an arithmetic circuit