{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE DerivingStrategies    #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-|
  Module      : Auth.Biscuit.Proto
  Copyright   : © Clément Delafargue, 2021
  License     : MIT
  Maintainer  : clement@delafargue.name
  Haskell data structures mapping the biscuit protobuf definitions
-}

module Auth.Biscuit.Proto
  ( Biscuit (..)
  , SignedBlock (..)
  , PublicKey (..)
  , Algorithm (..)
  , Proof (..)
  , Block (..)
  , FactV2 (..)
  , RuleV2 (..)
  , CheckV2 (..)
  , PredicateV2 (..)
  , TermV2 (..)
  , ExpressionV2 (..)
  , TermSet (..)
  , Op (..)
  , OpUnary (..)
  , UnaryKind (..)
  , OpBinary (..)
  , BinaryKind (..)
  , OpTernary (..)
  , TernaryKind (..)
  , getField
  , putField
  , decodeBlockList
  , decodeBlock
  , encodeBlockList
  , encodeBlock
  ) where

import           Data.ByteString      (ByteString)
import           Data.Int
import           Data.ProtocolBuffers
import           Data.Serialize
import           Data.Text
import           GHC.Generics         (Generic)

data Biscuit = Biscuit
  { Biscuit -> Optional 1 (Value Int32)
rootKeyId :: Optional 1 (Value Int32)
  , Biscuit -> Required 2 (Message SignedBlock)
authority :: Required 2 (Message SignedBlock)
  , Biscuit -> Repeated 3 (Message SignedBlock)
blocks    :: Repeated 3 (Message SignedBlock)
  , Biscuit -> Required 4 (Message Proof)
proof     :: Required 4 (Message Proof)
  } deriving ((forall x. Biscuit -> Rep Biscuit x)
-> (forall x. Rep Biscuit x -> Biscuit) -> Generic Biscuit
forall x. Rep Biscuit x -> Biscuit
forall x. Biscuit -> Rep Biscuit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Biscuit x -> Biscuit
$cfrom :: forall x. Biscuit -> Rep Biscuit x
Generic, Int -> Biscuit -> ShowS
[Biscuit] -> ShowS
Biscuit -> String
(Int -> Biscuit -> ShowS)
-> (Biscuit -> String) -> ([Biscuit] -> ShowS) -> Show Biscuit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Biscuit] -> ShowS
$cshowList :: [Biscuit] -> ShowS
show :: Biscuit -> String
$cshow :: Biscuit -> String
showsPrec :: Int -> Biscuit -> ShowS
$cshowsPrec :: Int -> Biscuit -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get Biscuit
(HashMap Tag [WireField] -> Get Biscuit) -> Decode Biscuit
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get Biscuit
$cdecode :: HashMap Tag [WireField] -> Get Biscuit
Decode, Biscuit -> Put
(Biscuit -> Put) -> Encode Biscuit
forall a. (a -> Put) -> Encode a
encode :: Biscuit -> Put
$cencode :: Biscuit -> Put
Encode)

data Proof =
    ProofSecret    (Required 1 (Value ByteString))
  | ProofSignature (Required 2 (Value ByteString))
  deriving ((forall x. Proof -> Rep Proof x)
-> (forall x. Rep Proof x -> Proof) -> Generic Proof
forall x. Rep Proof x -> Proof
forall x. Proof -> Rep Proof x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Proof x -> Proof
$cfrom :: forall x. Proof -> Rep Proof x
Generic, Int -> Proof -> ShowS
[Proof] -> ShowS
Proof -> String
(Int -> Proof -> ShowS)
-> (Proof -> String) -> ([Proof] -> ShowS) -> Show Proof
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Proof] -> ShowS
$cshowList :: [Proof] -> ShowS
show :: Proof -> String
$cshow :: Proof -> String
showsPrec :: Int -> Proof -> ShowS
$cshowsPrec :: Int -> Proof -> ShowS
Show)
  deriving anyclass (HashMap Tag [WireField] -> Get Proof
(HashMap Tag [WireField] -> Get Proof) -> Decode Proof
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get Proof
$cdecode :: HashMap Tag [WireField] -> Get Proof
Decode, Proof -> Put
(Proof -> Put) -> Encode Proof
forall a. (a -> Put) -> Encode a
encode :: Proof -> Put
$cencode :: Proof -> Put
Encode)

data SignedBlock = SignedBlock
  { SignedBlock -> Required 1 (Value ByteString)
block     :: Required 1 (Value ByteString)
  , SignedBlock -> Required 2 (Message PublicKey)
nextKey   :: Required 2 (Message PublicKey)
  , SignedBlock -> Required 3 (Value ByteString)
signature :: Required 3 (Value ByteString)
  }
  deriving ((forall x. SignedBlock -> Rep SignedBlock x)
-> (forall x. Rep SignedBlock x -> SignedBlock)
-> Generic SignedBlock
forall x. Rep SignedBlock x -> SignedBlock
forall x. SignedBlock -> Rep SignedBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignedBlock x -> SignedBlock
$cfrom :: forall x. SignedBlock -> Rep SignedBlock x
Generic, Int -> SignedBlock -> ShowS
[SignedBlock] -> ShowS
SignedBlock -> String
(Int -> SignedBlock -> ShowS)
-> (SignedBlock -> String)
-> ([SignedBlock] -> ShowS)
-> Show SignedBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignedBlock] -> ShowS
$cshowList :: [SignedBlock] -> ShowS
show :: SignedBlock -> String
$cshow :: SignedBlock -> String
showsPrec :: Int -> SignedBlock -> ShowS
$cshowsPrec :: Int -> SignedBlock -> ShowS
Show)
  deriving anyclass (HashMap Tag [WireField] -> Get SignedBlock
(HashMap Tag [WireField] -> Get SignedBlock) -> Decode SignedBlock
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get SignedBlock
$cdecode :: HashMap Tag [WireField] -> Get SignedBlock
Decode, SignedBlock -> Put
(SignedBlock -> Put) -> Encode SignedBlock
forall a. (a -> Put) -> Encode a
encode :: SignedBlock -> Put
$cencode :: SignedBlock -> Put
Encode)

data Algorithm = Ed25519
  deriving stock (Int -> Algorithm -> ShowS
[Algorithm] -> ShowS
Algorithm -> String
(Int -> Algorithm -> ShowS)
-> (Algorithm -> String)
-> ([Algorithm] -> ShowS)
-> Show Algorithm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Algorithm] -> ShowS
$cshowList :: [Algorithm] -> ShowS
show :: Algorithm -> String
$cshow :: Algorithm -> String
showsPrec :: Int -> Algorithm -> ShowS
$cshowsPrec :: Int -> Algorithm -> ShowS
Show, Int -> Algorithm
Algorithm -> Int
Algorithm -> [Algorithm]
Algorithm -> Algorithm
Algorithm -> Algorithm -> [Algorithm]
Algorithm -> Algorithm -> Algorithm -> [Algorithm]
(Algorithm -> Algorithm)
-> (Algorithm -> Algorithm)
-> (Int -> Algorithm)
-> (Algorithm -> Int)
-> (Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> Algorithm -> [Algorithm])
-> Enum Algorithm
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
$cenumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
enumFromTo :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromTo :: Algorithm -> Algorithm -> [Algorithm]
enumFromThen :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromThen :: Algorithm -> Algorithm -> [Algorithm]
enumFrom :: Algorithm -> [Algorithm]
$cenumFrom :: Algorithm -> [Algorithm]
fromEnum :: Algorithm -> Int
$cfromEnum :: Algorithm -> Int
toEnum :: Int -> Algorithm
$ctoEnum :: Int -> Algorithm
pred :: Algorithm -> Algorithm
$cpred :: Algorithm -> Algorithm
succ :: Algorithm -> Algorithm
$csucc :: Algorithm -> Algorithm
Enum, Algorithm
Algorithm -> Algorithm -> Bounded Algorithm
forall a. a -> a -> Bounded a
maxBound :: Algorithm
$cmaxBound :: Algorithm
minBound :: Algorithm
$cminBound :: Algorithm
Bounded)

data PublicKey = PublicKey
  { PublicKey -> Required 1 (Enumeration Algorithm)
algorithm :: Required 1 (Enumeration Algorithm)
  , PublicKey -> Required 2 (Value ByteString)
key       :: Required 2 (Value ByteString)
  }
  deriving ((forall x. PublicKey -> Rep PublicKey x)
-> (forall x. Rep PublicKey x -> PublicKey) -> Generic PublicKey
forall x. Rep PublicKey x -> PublicKey
forall x. PublicKey -> Rep PublicKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicKey x -> PublicKey
$cfrom :: forall x. PublicKey -> Rep PublicKey x
Generic, Int -> PublicKey -> ShowS
[PublicKey] -> ShowS
PublicKey -> String
(Int -> PublicKey -> ShowS)
-> (PublicKey -> String)
-> ([PublicKey] -> ShowS)
-> Show PublicKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicKey] -> ShowS
$cshowList :: [PublicKey] -> ShowS
show :: PublicKey -> String
$cshow :: PublicKey -> String
showsPrec :: Int -> PublicKey -> ShowS
$cshowsPrec :: Int -> PublicKey -> ShowS
Show)
  deriving anyclass (HashMap Tag [WireField] -> Get PublicKey
(HashMap Tag [WireField] -> Get PublicKey) -> Decode PublicKey
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get PublicKey
$cdecode :: HashMap Tag [WireField] -> Get PublicKey
Decode, PublicKey -> Put
(PublicKey -> Put) -> Encode PublicKey
forall a. (a -> Put) -> Encode a
encode :: PublicKey -> Put
$cencode :: PublicKey -> Put
Encode)

data Block = Block {
    Block -> Repeated 1 (Value Text)
symbols   :: Repeated 1 (Value Text)
  , Block -> Optional 2 (Value Text)
context   :: Optional 2 (Value Text)
  , Block -> Optional 3 (Value Int32)
version   :: Optional 3 (Value Int32)
  , Block -> Repeated 4 (Message FactV2)
facts_v2  :: Repeated 4 (Message FactV2)
  , Block -> Repeated 5 (Message RuleV2)
rules_v2  :: Repeated 5 (Message RuleV2)
  , Block -> Repeated 6 (Message CheckV2)
checks_v2 :: Repeated 6 (Message CheckV2)
  } deriving ((forall x. Block -> Rep Block x)
-> (forall x. Rep Block x -> Block) -> Generic Block
forall x. Rep Block x -> Block
forall x. Block -> Rep Block x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Block x -> Block
$cfrom :: forall x. Block -> Rep Block x
Generic, Int -> Block -> ShowS
[Block] -> ShowS
Block -> String
(Int -> Block -> ShowS)
-> (Block -> String) -> ([Block] -> ShowS) -> Show Block
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Block] -> ShowS
$cshowList :: [Block] -> ShowS
show :: Block -> String
$cshow :: Block -> String
showsPrec :: Int -> Block -> ShowS
$cshowsPrec :: Int -> Block -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get Block
(HashMap Tag [WireField] -> Get Block) -> Decode Block
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get Block
$cdecode :: HashMap Tag [WireField] -> Get Block
Decode, Block -> Put
(Block -> Put) -> Encode Block
forall a. (a -> Put) -> Encode a
encode :: Block -> Put
$cencode :: Block -> Put
Encode)

newtype FactV2 = FactV2
  { FactV2 -> Required 1 (Message PredicateV2)
predicate :: Required 1 (Message PredicateV2)
  } deriving stock ((forall x. FactV2 -> Rep FactV2 x)
-> (forall x. Rep FactV2 x -> FactV2) -> Generic FactV2
forall x. Rep FactV2 x -> FactV2
forall x. FactV2 -> Rep FactV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FactV2 x -> FactV2
$cfrom :: forall x. FactV2 -> Rep FactV2 x
Generic, Int -> FactV2 -> ShowS
[FactV2] -> ShowS
FactV2 -> String
(Int -> FactV2 -> ShowS)
-> (FactV2 -> String) -> ([FactV2] -> ShowS) -> Show FactV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FactV2] -> ShowS
$cshowList :: [FactV2] -> ShowS
show :: FactV2 -> String
$cshow :: FactV2 -> String
showsPrec :: Int -> FactV2 -> ShowS
$cshowsPrec :: Int -> FactV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get FactV2
(HashMap Tag [WireField] -> Get FactV2) -> Decode FactV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get FactV2
$cdecode :: HashMap Tag [WireField] -> Get FactV2
Decode, FactV2 -> Put
(FactV2 -> Put) -> Encode FactV2
forall a. (a -> Put) -> Encode a
encode :: FactV2 -> Put
$cencode :: FactV2 -> Put
Encode)

data RuleV2 = RuleV2
  { RuleV2 -> Required 1 (Message PredicateV2)
head        :: Required 1 (Message PredicateV2)
  , RuleV2 -> Repeated 2 (Message PredicateV2)
body        :: Repeated 2 (Message PredicateV2)
  , RuleV2 -> Repeated 3 (Message ExpressionV2)
expressions :: Repeated 3 (Message ExpressionV2)
  } deriving stock ((forall x. RuleV2 -> Rep RuleV2 x)
-> (forall x. Rep RuleV2 x -> RuleV2) -> Generic RuleV2
forall x. Rep RuleV2 x -> RuleV2
forall x. RuleV2 -> Rep RuleV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleV2 x -> RuleV2
$cfrom :: forall x. RuleV2 -> Rep RuleV2 x
Generic, Int -> RuleV2 -> ShowS
[RuleV2] -> ShowS
RuleV2 -> String
(Int -> RuleV2 -> ShowS)
-> (RuleV2 -> String) -> ([RuleV2] -> ShowS) -> Show RuleV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleV2] -> ShowS
$cshowList :: [RuleV2] -> ShowS
show :: RuleV2 -> String
$cshow :: RuleV2 -> String
showsPrec :: Int -> RuleV2 -> ShowS
$cshowsPrec :: Int -> RuleV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get RuleV2
(HashMap Tag [WireField] -> Get RuleV2) -> Decode RuleV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get RuleV2
$cdecode :: HashMap Tag [WireField] -> Get RuleV2
Decode, RuleV2 -> Put
(RuleV2 -> Put) -> Encode RuleV2
forall a. (a -> Put) -> Encode a
encode :: RuleV2 -> Put
$cencode :: RuleV2 -> Put
Encode)

newtype CheckV2 = CheckV2
  { CheckV2 -> Repeated 1 (Message RuleV2)
queries :: Repeated 1 (Message RuleV2)
  } deriving stock ((forall x. CheckV2 -> Rep CheckV2 x)
-> (forall x. Rep CheckV2 x -> CheckV2) -> Generic CheckV2
forall x. Rep CheckV2 x -> CheckV2
forall x. CheckV2 -> Rep CheckV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CheckV2 x -> CheckV2
$cfrom :: forall x. CheckV2 -> Rep CheckV2 x
Generic, Int -> CheckV2 -> ShowS
[CheckV2] -> ShowS
CheckV2 -> String
(Int -> CheckV2 -> ShowS)
-> (CheckV2 -> String) -> ([CheckV2] -> ShowS) -> Show CheckV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckV2] -> ShowS
$cshowList :: [CheckV2] -> ShowS
show :: CheckV2 -> String
$cshow :: CheckV2 -> String
showsPrec :: Int -> CheckV2 -> ShowS
$cshowsPrec :: Int -> CheckV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get CheckV2
(HashMap Tag [WireField] -> Get CheckV2) -> Decode CheckV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get CheckV2
$cdecode :: HashMap Tag [WireField] -> Get CheckV2
Decode, CheckV2 -> Put
(CheckV2 -> Put) -> Encode CheckV2
forall a. (a -> Put) -> Encode a
encode :: CheckV2 -> Put
$cencode :: CheckV2 -> Put
Encode)

data PredicateV2 = PredicateV2
  { PredicateV2 -> Required 1 (Value Int64)
name  :: Required 1 (Value Int64)
  , PredicateV2 -> Repeated 2 (Message TermV2)
terms :: Repeated 2 (Message TermV2)
  } deriving stock ((forall x. PredicateV2 -> Rep PredicateV2 x)
-> (forall x. Rep PredicateV2 x -> PredicateV2)
-> Generic PredicateV2
forall x. Rep PredicateV2 x -> PredicateV2
forall x. PredicateV2 -> Rep PredicateV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredicateV2 x -> PredicateV2
$cfrom :: forall x. PredicateV2 -> Rep PredicateV2 x
Generic, Int -> PredicateV2 -> ShowS
[PredicateV2] -> ShowS
PredicateV2 -> String
(Int -> PredicateV2 -> ShowS)
-> (PredicateV2 -> String)
-> ([PredicateV2] -> ShowS)
-> Show PredicateV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredicateV2] -> ShowS
$cshowList :: [PredicateV2] -> ShowS
show :: PredicateV2 -> String
$cshow :: PredicateV2 -> String
showsPrec :: Int -> PredicateV2 -> ShowS
$cshowsPrec :: Int -> PredicateV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get PredicateV2
(HashMap Tag [WireField] -> Get PredicateV2) -> Decode PredicateV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get PredicateV2
$cdecode :: HashMap Tag [WireField] -> Get PredicateV2
Decode, PredicateV2 -> Put
(PredicateV2 -> Put) -> Encode PredicateV2
forall a. (a -> Put) -> Encode a
encode :: PredicateV2 -> Put
$cencode :: PredicateV2 -> Put
Encode)

data TermV2 =
    TermVariable (Required 1 (Value Int32))
  | TermInteger  (Required 2 (Value Int64))
  | TermString   (Required 3 (Value Int64))
  | TermDate     (Required 4 (Value Int64))
  | TermBytes    (Required 5 (Value ByteString))
  | TermBool     (Required 6 (Value Bool))
  | TermTermSet  (Required 7 (Message TermSet))
    deriving stock ((forall x. TermV2 -> Rep TermV2 x)
-> (forall x. Rep TermV2 x -> TermV2) -> Generic TermV2
forall x. Rep TermV2 x -> TermV2
forall x. TermV2 -> Rep TermV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TermV2 x -> TermV2
$cfrom :: forall x. TermV2 -> Rep TermV2 x
Generic, Int -> TermV2 -> ShowS
[TermV2] -> ShowS
TermV2 -> String
(Int -> TermV2 -> ShowS)
-> (TermV2 -> String) -> ([TermV2] -> ShowS) -> Show TermV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TermV2] -> ShowS
$cshowList :: [TermV2] -> ShowS
show :: TermV2 -> String
$cshow :: TermV2 -> String
showsPrec :: Int -> TermV2 -> ShowS
$cshowsPrec :: Int -> TermV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get TermV2
(HashMap Tag [WireField] -> Get TermV2) -> Decode TermV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get TermV2
$cdecode :: HashMap Tag [WireField] -> Get TermV2
Decode, TermV2 -> Put
(TermV2 -> Put) -> Encode TermV2
forall a. (a -> Put) -> Encode a
encode :: TermV2 -> Put
$cencode :: TermV2 -> Put
Encode)


newtype TermSet = TermSet
  { TermSet -> Repeated 1 (Message TermV2)
set :: Repeated 1 (Message TermV2)
  } deriving stock ((forall x. TermSet -> Rep TermSet x)
-> (forall x. Rep TermSet x -> TermSet) -> Generic TermSet
forall x. Rep TermSet x -> TermSet
forall x. TermSet -> Rep TermSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TermSet x -> TermSet
$cfrom :: forall x. TermSet -> Rep TermSet x
Generic, Int -> TermSet -> ShowS
[TermSet] -> ShowS
TermSet -> String
(Int -> TermSet -> ShowS)
-> (TermSet -> String) -> ([TermSet] -> ShowS) -> Show TermSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TermSet] -> ShowS
$cshowList :: [TermSet] -> ShowS
show :: TermSet -> String
$cshow :: TermSet -> String
showsPrec :: Int -> TermSet -> ShowS
$cshowsPrec :: Int -> TermSet -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get TermSet
(HashMap Tag [WireField] -> Get TermSet) -> Decode TermSet
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get TermSet
$cdecode :: HashMap Tag [WireField] -> Get TermSet
Decode, TermSet -> Put
(TermSet -> Put) -> Encode TermSet
forall a. (a -> Put) -> Encode a
encode :: TermSet -> Put
$cencode :: TermSet -> Put
Encode)

type CV2Id = Required 1 (Value Int32)
data ConstraintV2 =
    CV2Int    CV2Id (Required 2 (Message IntConstraintV2))
  | CV2String CV2Id (Required 3 (Message StringConstraintV2))
  | CV2Date   CV2Id (Required 4 (Message DateConstraintV2))
  | CV2Symbol CV2Id (Required 5 (Message SymbolConstraintV2))
  | CV2Bytes  CV2Id (Required 6 (Message BytesConstraintV2))
    deriving stock ((forall x. ConstraintV2 -> Rep ConstraintV2 x)
-> (forall x. Rep ConstraintV2 x -> ConstraintV2)
-> Generic ConstraintV2
forall x. Rep ConstraintV2 x -> ConstraintV2
forall x. ConstraintV2 -> Rep ConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConstraintV2 x -> ConstraintV2
$cfrom :: forall x. ConstraintV2 -> Rep ConstraintV2 x
Generic, Int -> ConstraintV2 -> ShowS
[ConstraintV2] -> ShowS
ConstraintV2 -> String
(Int -> ConstraintV2 -> ShowS)
-> (ConstraintV2 -> String)
-> ([ConstraintV2] -> ShowS)
-> Show ConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConstraintV2] -> ShowS
$cshowList :: [ConstraintV2] -> ShowS
show :: ConstraintV2 -> String
$cshow :: ConstraintV2 -> String
showsPrec :: Int -> ConstraintV2 -> ShowS
$cshowsPrec :: Int -> ConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get ConstraintV2
(HashMap Tag [WireField] -> Get ConstraintV2)
-> Decode ConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get ConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get ConstraintV2
Decode, ConstraintV2 -> Put
(ConstraintV2 -> Put) -> Encode ConstraintV2
forall a. (a -> Put) -> Encode a
encode :: ConstraintV2 -> Put
$cencode :: ConstraintV2 -> Put
Encode)

data IntConstraintV2 =
    ICV2LessThan       (Required 1 (Value Int64))
  | ICV2GreaterThan    (Required 2 (Value Int64))
  | ICV2LessOrEqual    (Required 3 (Value Int64))
  | ICV2GreaterOrEqual (Required 4 (Value Int64))
  | ICV2Equal          (Required 5 (Value Int64))
  | ICV2InSet          (Required 6 (Message IntSet))
  | ICV2NotInSet       (Required 7 (Message IntSet))
    deriving stock ((forall x. IntConstraintV2 -> Rep IntConstraintV2 x)
-> (forall x. Rep IntConstraintV2 x -> IntConstraintV2)
-> Generic IntConstraintV2
forall x. Rep IntConstraintV2 x -> IntConstraintV2
forall x. IntConstraintV2 -> Rep IntConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntConstraintV2 x -> IntConstraintV2
$cfrom :: forall x. IntConstraintV2 -> Rep IntConstraintV2 x
Generic, Int -> IntConstraintV2 -> ShowS
[IntConstraintV2] -> ShowS
IntConstraintV2 -> String
(Int -> IntConstraintV2 -> ShowS)
-> (IntConstraintV2 -> String)
-> ([IntConstraintV2] -> ShowS)
-> Show IntConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntConstraintV2] -> ShowS
$cshowList :: [IntConstraintV2] -> ShowS
show :: IntConstraintV2 -> String
$cshow :: IntConstraintV2 -> String
showsPrec :: Int -> IntConstraintV2 -> ShowS
$cshowsPrec :: Int -> IntConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get IntConstraintV2
(HashMap Tag [WireField] -> Get IntConstraintV2)
-> Decode IntConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get IntConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get IntConstraintV2
Decode, IntConstraintV2 -> Put
(IntConstraintV2 -> Put) -> Encode IntConstraintV2
forall a. (a -> Put) -> Encode a
encode :: IntConstraintV2 -> Put
$cencode :: IntConstraintV2 -> Put
Encode)

newtype IntSet = IntSet
  { IntSet -> Packed 7 (Value Int64)
set :: Packed 7 (Value Int64)
  } deriving stock ((forall x. IntSet -> Rep IntSet x)
-> (forall x. Rep IntSet x -> IntSet) -> Generic IntSet
forall x. Rep IntSet x -> IntSet
forall x. IntSet -> Rep IntSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntSet x -> IntSet
$cfrom :: forall x. IntSet -> Rep IntSet x
Generic, Int -> IntSet -> ShowS
[IntSet] -> ShowS
IntSet -> String
(Int -> IntSet -> ShowS)
-> (IntSet -> String) -> ([IntSet] -> ShowS) -> Show IntSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntSet] -> ShowS
$cshowList :: [IntSet] -> ShowS
show :: IntSet -> String
$cshow :: IntSet -> String
showsPrec :: Int -> IntSet -> ShowS
$cshowsPrec :: Int -> IntSet -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get IntSet
(HashMap Tag [WireField] -> Get IntSet) -> Decode IntSet
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get IntSet
$cdecode :: HashMap Tag [WireField] -> Get IntSet
Decode, IntSet -> Put
(IntSet -> Put) -> Encode IntSet
forall a. (a -> Put) -> Encode a
encode :: IntSet -> Put
$cencode :: IntSet -> Put
Encode)

data StringConstraintV2 =
    SCV2Prefix   (Required 1 (Value Text))
  | SCV2Suffix   (Required 2 (Value Text))
  | SCV2Equal    (Required 3 (Value Text))
  | SCV2InSet    (Required 4 (Message StringSet))
  | SCV2NotInSet (Required 5 (Message StringSet))
  | SCV2Regex    (Required 6 (Value Text))
    deriving stock ((forall x. StringConstraintV2 -> Rep StringConstraintV2 x)
-> (forall x. Rep StringConstraintV2 x -> StringConstraintV2)
-> Generic StringConstraintV2
forall x. Rep StringConstraintV2 x -> StringConstraintV2
forall x. StringConstraintV2 -> Rep StringConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StringConstraintV2 x -> StringConstraintV2
$cfrom :: forall x. StringConstraintV2 -> Rep StringConstraintV2 x
Generic, Int -> StringConstraintV2 -> ShowS
[StringConstraintV2] -> ShowS
StringConstraintV2 -> String
(Int -> StringConstraintV2 -> ShowS)
-> (StringConstraintV2 -> String)
-> ([StringConstraintV2] -> ShowS)
-> Show StringConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringConstraintV2] -> ShowS
$cshowList :: [StringConstraintV2] -> ShowS
show :: StringConstraintV2 -> String
$cshow :: StringConstraintV2 -> String
showsPrec :: Int -> StringConstraintV2 -> ShowS
$cshowsPrec :: Int -> StringConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get StringConstraintV2
(HashMap Tag [WireField] -> Get StringConstraintV2)
-> Decode StringConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get StringConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get StringConstraintV2
Decode, StringConstraintV2 -> Put
(StringConstraintV2 -> Put) -> Encode StringConstraintV2
forall a. (a -> Put) -> Encode a
encode :: StringConstraintV2 -> Put
$cencode :: StringConstraintV2 -> Put
Encode)

newtype StringSet = StringSet
  { StringSet -> Repeated 1 (Value Text)
set :: Repeated 1 (Value Text)
  } deriving stock ((forall x. StringSet -> Rep StringSet x)
-> (forall x. Rep StringSet x -> StringSet) -> Generic StringSet
forall x. Rep StringSet x -> StringSet
forall x. StringSet -> Rep StringSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StringSet x -> StringSet
$cfrom :: forall x. StringSet -> Rep StringSet x
Generic, Int -> StringSet -> ShowS
[StringSet] -> ShowS
StringSet -> String
(Int -> StringSet -> ShowS)
-> (StringSet -> String)
-> ([StringSet] -> ShowS)
-> Show StringSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringSet] -> ShowS
$cshowList :: [StringSet] -> ShowS
show :: StringSet -> String
$cshow :: StringSet -> String
showsPrec :: Int -> StringSet -> ShowS
$cshowsPrec :: Int -> StringSet -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get StringSet
(HashMap Tag [WireField] -> Get StringSet) -> Decode StringSet
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get StringSet
$cdecode :: HashMap Tag [WireField] -> Get StringSet
Decode, StringSet -> Put
(StringSet -> Put) -> Encode StringSet
forall a. (a -> Put) -> Encode a
encode :: StringSet -> Put
$cencode :: StringSet -> Put
Encode)

data DateConstraintV2 =
    DCV2Before (Required 1 (Value Int64))
  | DCV2After  (Required 2 (Value Int64))
    deriving stock ((forall x. DateConstraintV2 -> Rep DateConstraintV2 x)
-> (forall x. Rep DateConstraintV2 x -> DateConstraintV2)
-> Generic DateConstraintV2
forall x. Rep DateConstraintV2 x -> DateConstraintV2
forall x. DateConstraintV2 -> Rep DateConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DateConstraintV2 x -> DateConstraintV2
$cfrom :: forall x. DateConstraintV2 -> Rep DateConstraintV2 x
Generic, Int -> DateConstraintV2 -> ShowS
[DateConstraintV2] -> ShowS
DateConstraintV2 -> String
(Int -> DateConstraintV2 -> ShowS)
-> (DateConstraintV2 -> String)
-> ([DateConstraintV2] -> ShowS)
-> Show DateConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DateConstraintV2] -> ShowS
$cshowList :: [DateConstraintV2] -> ShowS
show :: DateConstraintV2 -> String
$cshow :: DateConstraintV2 -> String
showsPrec :: Int -> DateConstraintV2 -> ShowS
$cshowsPrec :: Int -> DateConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get DateConstraintV2
(HashMap Tag [WireField] -> Get DateConstraintV2)
-> Decode DateConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get DateConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get DateConstraintV2
Decode, DateConstraintV2 -> Put
(DateConstraintV2 -> Put) -> Encode DateConstraintV2
forall a. (a -> Put) -> Encode a
encode :: DateConstraintV2 -> Put
$cencode :: DateConstraintV2 -> Put
Encode)

data SymbolConstraintV2 =
    SyCV2InSet    (Required 1 (Message SymbolSet))
  | SyCV2NotInSet (Required 2 (Message SymbolSet))
    deriving stock ((forall x. SymbolConstraintV2 -> Rep SymbolConstraintV2 x)
-> (forall x. Rep SymbolConstraintV2 x -> SymbolConstraintV2)
-> Generic SymbolConstraintV2
forall x. Rep SymbolConstraintV2 x -> SymbolConstraintV2
forall x. SymbolConstraintV2 -> Rep SymbolConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SymbolConstraintV2 x -> SymbolConstraintV2
$cfrom :: forall x. SymbolConstraintV2 -> Rep SymbolConstraintV2 x
Generic, Int -> SymbolConstraintV2 -> ShowS
[SymbolConstraintV2] -> ShowS
SymbolConstraintV2 -> String
(Int -> SymbolConstraintV2 -> ShowS)
-> (SymbolConstraintV2 -> String)
-> ([SymbolConstraintV2] -> ShowS)
-> Show SymbolConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SymbolConstraintV2] -> ShowS
$cshowList :: [SymbolConstraintV2] -> ShowS
show :: SymbolConstraintV2 -> String
$cshow :: SymbolConstraintV2 -> String
showsPrec :: Int -> SymbolConstraintV2 -> ShowS
$cshowsPrec :: Int -> SymbolConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get SymbolConstraintV2
(HashMap Tag [WireField] -> Get SymbolConstraintV2)
-> Decode SymbolConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get SymbolConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get SymbolConstraintV2
Decode, SymbolConstraintV2 -> Put
(SymbolConstraintV2 -> Put) -> Encode SymbolConstraintV2
forall a. (a -> Put) -> Encode a
encode :: SymbolConstraintV2 -> Put
$cencode :: SymbolConstraintV2 -> Put
Encode)

newtype SymbolSet = SymbolSet
  { SymbolSet -> Packed 1 (Value Int64)
set :: Packed 1 (Value Int64)
  } deriving stock ((forall x. SymbolSet -> Rep SymbolSet x)
-> (forall x. Rep SymbolSet x -> SymbolSet) -> Generic SymbolSet
forall x. Rep SymbolSet x -> SymbolSet
forall x. SymbolSet -> Rep SymbolSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SymbolSet x -> SymbolSet
$cfrom :: forall x. SymbolSet -> Rep SymbolSet x
Generic, Int -> SymbolSet -> ShowS
[SymbolSet] -> ShowS
SymbolSet -> String
(Int -> SymbolSet -> ShowS)
-> (SymbolSet -> String)
-> ([SymbolSet] -> ShowS)
-> Show SymbolSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SymbolSet] -> ShowS
$cshowList :: [SymbolSet] -> ShowS
show :: SymbolSet -> String
$cshow :: SymbolSet -> String
showsPrec :: Int -> SymbolSet -> ShowS
$cshowsPrec :: Int -> SymbolSet -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get SymbolSet
(HashMap Tag [WireField] -> Get SymbolSet) -> Decode SymbolSet
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get SymbolSet
$cdecode :: HashMap Tag [WireField] -> Get SymbolSet
Decode, SymbolSet -> Put
(SymbolSet -> Put) -> Encode SymbolSet
forall a. (a -> Put) -> Encode a
encode :: SymbolSet -> Put
$cencode :: SymbolSet -> Put
Encode)


data BytesConstraintV2 =
    BCV2Equal    (Required 1 (Value ByteString))
  | BCV2InSet    (Required 2 (Message BytesSet))
  | BCV2NotInSet (Required 3 (Message BytesSet))
    deriving stock ((forall x. BytesConstraintV2 -> Rep BytesConstraintV2 x)
-> (forall x. Rep BytesConstraintV2 x -> BytesConstraintV2)
-> Generic BytesConstraintV2
forall x. Rep BytesConstraintV2 x -> BytesConstraintV2
forall x. BytesConstraintV2 -> Rep BytesConstraintV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BytesConstraintV2 x -> BytesConstraintV2
$cfrom :: forall x. BytesConstraintV2 -> Rep BytesConstraintV2 x
Generic, Int -> BytesConstraintV2 -> ShowS
[BytesConstraintV2] -> ShowS
BytesConstraintV2 -> String
(Int -> BytesConstraintV2 -> ShowS)
-> (BytesConstraintV2 -> String)
-> ([BytesConstraintV2] -> ShowS)
-> Show BytesConstraintV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BytesConstraintV2] -> ShowS
$cshowList :: [BytesConstraintV2] -> ShowS
show :: BytesConstraintV2 -> String
$cshow :: BytesConstraintV2 -> String
showsPrec :: Int -> BytesConstraintV2 -> ShowS
$cshowsPrec :: Int -> BytesConstraintV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get BytesConstraintV2
(HashMap Tag [WireField] -> Get BytesConstraintV2)
-> Decode BytesConstraintV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get BytesConstraintV2
$cdecode :: HashMap Tag [WireField] -> Get BytesConstraintV2
Decode, BytesConstraintV2 -> Put
(BytesConstraintV2 -> Put) -> Encode BytesConstraintV2
forall a. (a -> Put) -> Encode a
encode :: BytesConstraintV2 -> Put
$cencode :: BytesConstraintV2 -> Put
Encode)

newtype BytesSet = BytesSet
  { BytesSet -> Repeated 1 (Value ByteString)
set :: Repeated 1 (Value ByteString)
  } deriving stock ((forall x. BytesSet -> Rep BytesSet x)
-> (forall x. Rep BytesSet x -> BytesSet) -> Generic BytesSet
forall x. Rep BytesSet x -> BytesSet
forall x. BytesSet -> Rep BytesSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BytesSet x -> BytesSet
$cfrom :: forall x. BytesSet -> Rep BytesSet x
Generic, Int -> BytesSet -> ShowS
[BytesSet] -> ShowS
BytesSet -> String
(Int -> BytesSet -> ShowS)
-> (BytesSet -> String) -> ([BytesSet] -> ShowS) -> Show BytesSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BytesSet] -> ShowS
$cshowList :: [BytesSet] -> ShowS
show :: BytesSet -> String
$cshow :: BytesSet -> String
showsPrec :: Int -> BytesSet -> ShowS
$cshowsPrec :: Int -> BytesSet -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get BytesSet
(HashMap Tag [WireField] -> Get BytesSet) -> Decode BytesSet
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get BytesSet
$cdecode :: HashMap Tag [WireField] -> Get BytesSet
Decode, BytesSet -> Put
(BytesSet -> Put) -> Encode BytesSet
forall a. (a -> Put) -> Encode a
encode :: BytesSet -> Put
$cencode :: BytesSet -> Put
Encode)

newtype ExpressionV2 = ExpressionV2
  { ExpressionV2 -> Repeated 1 (Message Op)
ops :: Repeated 1 (Message Op)
  } deriving stock ((forall x. ExpressionV2 -> Rep ExpressionV2 x)
-> (forall x. Rep ExpressionV2 x -> ExpressionV2)
-> Generic ExpressionV2
forall x. Rep ExpressionV2 x -> ExpressionV2
forall x. ExpressionV2 -> Rep ExpressionV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExpressionV2 x -> ExpressionV2
$cfrom :: forall x. ExpressionV2 -> Rep ExpressionV2 x
Generic, Int -> ExpressionV2 -> ShowS
[ExpressionV2] -> ShowS
ExpressionV2 -> String
(Int -> ExpressionV2 -> ShowS)
-> (ExpressionV2 -> String)
-> ([ExpressionV2] -> ShowS)
-> Show ExpressionV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExpressionV2] -> ShowS
$cshowList :: [ExpressionV2] -> ShowS
show :: ExpressionV2 -> String
$cshow :: ExpressionV2 -> String
showsPrec :: Int -> ExpressionV2 -> ShowS
$cshowsPrec :: Int -> ExpressionV2 -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get ExpressionV2
(HashMap Tag [WireField] -> Get ExpressionV2)
-> Decode ExpressionV2
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get ExpressionV2
$cdecode :: HashMap Tag [WireField] -> Get ExpressionV2
Decode, ExpressionV2 -> Put
(ExpressionV2 -> Put) -> Encode ExpressionV2
forall a. (a -> Put) -> Encode a
encode :: ExpressionV2 -> Put
$cencode :: ExpressionV2 -> Put
Encode)

data Op =
    OpVValue  (Required 1 (Message TermV2))
  | OpVUnary  (Required 2 (Message OpUnary))
  | OpVBinary (Required 3 (Message OpBinary))
    deriving stock ((forall x. Op -> Rep Op x)
-> (forall x. Rep Op x -> Op) -> Generic Op
forall x. Rep Op x -> Op
forall x. Op -> Rep Op x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Op x -> Op
$cfrom :: forall x. Op -> Rep Op x
Generic, Int -> Op -> ShowS
[Op] -> ShowS
Op -> String
(Int -> Op -> ShowS)
-> (Op -> String) -> ([Op] -> ShowS) -> Show Op
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Op] -> ShowS
$cshowList :: [Op] -> ShowS
show :: Op -> String
$cshow :: Op -> String
showsPrec :: Int -> Op -> ShowS
$cshowsPrec :: Int -> Op -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get Op
(HashMap Tag [WireField] -> Get Op) -> Decode Op
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get Op
$cdecode :: HashMap Tag [WireField] -> Get Op
Decode, Op -> Put
(Op -> Put) -> Encode Op
forall a. (a -> Put) -> Encode a
encode :: Op -> Put
$cencode :: Op -> Put
Encode)

data UnaryKind = Negate | Parens | Length
  deriving stock (Int -> UnaryKind -> ShowS
[UnaryKind] -> ShowS
UnaryKind -> String
(Int -> UnaryKind -> ShowS)
-> (UnaryKind -> String)
-> ([UnaryKind] -> ShowS)
-> Show UnaryKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnaryKind] -> ShowS
$cshowList :: [UnaryKind] -> ShowS
show :: UnaryKind -> String
$cshow :: UnaryKind -> String
showsPrec :: Int -> UnaryKind -> ShowS
$cshowsPrec :: Int -> UnaryKind -> ShowS
Show, Int -> UnaryKind
UnaryKind -> Int
UnaryKind -> [UnaryKind]
UnaryKind -> UnaryKind
UnaryKind -> UnaryKind -> [UnaryKind]
UnaryKind -> UnaryKind -> UnaryKind -> [UnaryKind]
(UnaryKind -> UnaryKind)
-> (UnaryKind -> UnaryKind)
-> (Int -> UnaryKind)
-> (UnaryKind -> Int)
-> (UnaryKind -> [UnaryKind])
-> (UnaryKind -> UnaryKind -> [UnaryKind])
-> (UnaryKind -> UnaryKind -> [UnaryKind])
-> (UnaryKind -> UnaryKind -> UnaryKind -> [UnaryKind])
-> Enum UnaryKind
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: UnaryKind -> UnaryKind -> UnaryKind -> [UnaryKind]
$cenumFromThenTo :: UnaryKind -> UnaryKind -> UnaryKind -> [UnaryKind]
enumFromTo :: UnaryKind -> UnaryKind -> [UnaryKind]
$cenumFromTo :: UnaryKind -> UnaryKind -> [UnaryKind]
enumFromThen :: UnaryKind -> UnaryKind -> [UnaryKind]
$cenumFromThen :: UnaryKind -> UnaryKind -> [UnaryKind]
enumFrom :: UnaryKind -> [UnaryKind]
$cenumFrom :: UnaryKind -> [UnaryKind]
fromEnum :: UnaryKind -> Int
$cfromEnum :: UnaryKind -> Int
toEnum :: Int -> UnaryKind
$ctoEnum :: Int -> UnaryKind
pred :: UnaryKind -> UnaryKind
$cpred :: UnaryKind -> UnaryKind
succ :: UnaryKind -> UnaryKind
$csucc :: UnaryKind -> UnaryKind
Enum, UnaryKind
UnaryKind -> UnaryKind -> Bounded UnaryKind
forall a. a -> a -> Bounded a
maxBound :: UnaryKind
$cmaxBound :: UnaryKind
minBound :: UnaryKind
$cminBound :: UnaryKind
Bounded)

newtype OpUnary = OpUnary
  { OpUnary -> Required 1 (Enumeration UnaryKind)
kind :: Required 1 (Enumeration UnaryKind)
  } deriving stock ((forall x. OpUnary -> Rep OpUnary x)
-> (forall x. Rep OpUnary x -> OpUnary) -> Generic OpUnary
forall x. Rep OpUnary x -> OpUnary
forall x. OpUnary -> Rep OpUnary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpUnary x -> OpUnary
$cfrom :: forall x. OpUnary -> Rep OpUnary x
Generic, Int -> OpUnary -> ShowS
[OpUnary] -> ShowS
OpUnary -> String
(Int -> OpUnary -> ShowS)
-> (OpUnary -> String) -> ([OpUnary] -> ShowS) -> Show OpUnary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpUnary] -> ShowS
$cshowList :: [OpUnary] -> ShowS
show :: OpUnary -> String
$cshow :: OpUnary -> String
showsPrec :: Int -> OpUnary -> ShowS
$cshowsPrec :: Int -> OpUnary -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get OpUnary
(HashMap Tag [WireField] -> Get OpUnary) -> Decode OpUnary
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get OpUnary
$cdecode :: HashMap Tag [WireField] -> Get OpUnary
Decode, OpUnary -> Put
(OpUnary -> Put) -> Encode OpUnary
forall a. (a -> Put) -> Encode a
encode :: OpUnary -> Put
$cencode :: OpUnary -> Put
Encode)

data BinaryKind =
    LessThan
  | GreaterThan
  | LessOrEqual
  | GreaterOrEqual
  | Equal
  | Contains
  | Prefix
  | Suffix
  | Regex
  | Add
  | Sub
  | Mul
  | Div
  | And
  | Or
  | Intersection
  | Union
  deriving stock (Int -> BinaryKind -> ShowS
[BinaryKind] -> ShowS
BinaryKind -> String
(Int -> BinaryKind -> ShowS)
-> (BinaryKind -> String)
-> ([BinaryKind] -> ShowS)
-> Show BinaryKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinaryKind] -> ShowS
$cshowList :: [BinaryKind] -> ShowS
show :: BinaryKind -> String
$cshow :: BinaryKind -> String
showsPrec :: Int -> BinaryKind -> ShowS
$cshowsPrec :: Int -> BinaryKind -> ShowS
Show, Int -> BinaryKind
BinaryKind -> Int
BinaryKind -> [BinaryKind]
BinaryKind -> BinaryKind
BinaryKind -> BinaryKind -> [BinaryKind]
BinaryKind -> BinaryKind -> BinaryKind -> [BinaryKind]
(BinaryKind -> BinaryKind)
-> (BinaryKind -> BinaryKind)
-> (Int -> BinaryKind)
-> (BinaryKind -> Int)
-> (BinaryKind -> [BinaryKind])
-> (BinaryKind -> BinaryKind -> [BinaryKind])
-> (BinaryKind -> BinaryKind -> [BinaryKind])
-> (BinaryKind -> BinaryKind -> BinaryKind -> [BinaryKind])
-> Enum BinaryKind
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: BinaryKind -> BinaryKind -> BinaryKind -> [BinaryKind]
$cenumFromThenTo :: BinaryKind -> BinaryKind -> BinaryKind -> [BinaryKind]
enumFromTo :: BinaryKind -> BinaryKind -> [BinaryKind]
$cenumFromTo :: BinaryKind -> BinaryKind -> [BinaryKind]
enumFromThen :: BinaryKind -> BinaryKind -> [BinaryKind]
$cenumFromThen :: BinaryKind -> BinaryKind -> [BinaryKind]
enumFrom :: BinaryKind -> [BinaryKind]
$cenumFrom :: BinaryKind -> [BinaryKind]
fromEnum :: BinaryKind -> Int
$cfromEnum :: BinaryKind -> Int
toEnum :: Int -> BinaryKind
$ctoEnum :: Int -> BinaryKind
pred :: BinaryKind -> BinaryKind
$cpred :: BinaryKind -> BinaryKind
succ :: BinaryKind -> BinaryKind
$csucc :: BinaryKind -> BinaryKind
Enum, BinaryKind
BinaryKind -> BinaryKind -> Bounded BinaryKind
forall a. a -> a -> Bounded a
maxBound :: BinaryKind
$cmaxBound :: BinaryKind
minBound :: BinaryKind
$cminBound :: BinaryKind
Bounded)

newtype OpBinary = OpBinary
  { OpBinary -> Required 1 (Enumeration BinaryKind)
kind :: Required 1 (Enumeration BinaryKind)
  } deriving stock ((forall x. OpBinary -> Rep OpBinary x)
-> (forall x. Rep OpBinary x -> OpBinary) -> Generic OpBinary
forall x. Rep OpBinary x -> OpBinary
forall x. OpBinary -> Rep OpBinary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpBinary x -> OpBinary
$cfrom :: forall x. OpBinary -> Rep OpBinary x
Generic, Int -> OpBinary -> ShowS
[OpBinary] -> ShowS
OpBinary -> String
(Int -> OpBinary -> ShowS)
-> (OpBinary -> String) -> ([OpBinary] -> ShowS) -> Show OpBinary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpBinary] -> ShowS
$cshowList :: [OpBinary] -> ShowS
show :: OpBinary -> String
$cshow :: OpBinary -> String
showsPrec :: Int -> OpBinary -> ShowS
$cshowsPrec :: Int -> OpBinary -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get OpBinary
(HashMap Tag [WireField] -> Get OpBinary) -> Decode OpBinary
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get OpBinary
$cdecode :: HashMap Tag [WireField] -> Get OpBinary
Decode, OpBinary -> Put
(OpBinary -> Put) -> Encode OpBinary
forall a. (a -> Put) -> Encode a
encode :: OpBinary -> Put
$cencode :: OpBinary -> Put
Encode)

data TernaryKind =
    VerifyEd25519Signature
  deriving stock (Int -> TernaryKind -> ShowS
[TernaryKind] -> ShowS
TernaryKind -> String
(Int -> TernaryKind -> ShowS)
-> (TernaryKind -> String)
-> ([TernaryKind] -> ShowS)
-> Show TernaryKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TernaryKind] -> ShowS
$cshowList :: [TernaryKind] -> ShowS
show :: TernaryKind -> String
$cshow :: TernaryKind -> String
showsPrec :: Int -> TernaryKind -> ShowS
$cshowsPrec :: Int -> TernaryKind -> ShowS
Show, Int -> TernaryKind
TernaryKind -> Int
TernaryKind -> [TernaryKind]
TernaryKind -> TernaryKind
TernaryKind -> TernaryKind -> [TernaryKind]
TernaryKind -> TernaryKind -> TernaryKind -> [TernaryKind]
(TernaryKind -> TernaryKind)
-> (TernaryKind -> TernaryKind)
-> (Int -> TernaryKind)
-> (TernaryKind -> Int)
-> (TernaryKind -> [TernaryKind])
-> (TernaryKind -> TernaryKind -> [TernaryKind])
-> (TernaryKind -> TernaryKind -> [TernaryKind])
-> (TernaryKind -> TernaryKind -> TernaryKind -> [TernaryKind])
-> Enum TernaryKind
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: TernaryKind -> TernaryKind -> TernaryKind -> [TernaryKind]
$cenumFromThenTo :: TernaryKind -> TernaryKind -> TernaryKind -> [TernaryKind]
enumFromTo :: TernaryKind -> TernaryKind -> [TernaryKind]
$cenumFromTo :: TernaryKind -> TernaryKind -> [TernaryKind]
enumFromThen :: TernaryKind -> TernaryKind -> [TernaryKind]
$cenumFromThen :: TernaryKind -> TernaryKind -> [TernaryKind]
enumFrom :: TernaryKind -> [TernaryKind]
$cenumFrom :: TernaryKind -> [TernaryKind]
fromEnum :: TernaryKind -> Int
$cfromEnum :: TernaryKind -> Int
toEnum :: Int -> TernaryKind
$ctoEnum :: Int -> TernaryKind
pred :: TernaryKind -> TernaryKind
$cpred :: TernaryKind -> TernaryKind
succ :: TernaryKind -> TernaryKind
$csucc :: TernaryKind -> TernaryKind
Enum, TernaryKind
TernaryKind -> TernaryKind -> Bounded TernaryKind
forall a. a -> a -> Bounded a
maxBound :: TernaryKind
$cmaxBound :: TernaryKind
minBound :: TernaryKind
$cminBound :: TernaryKind
Bounded)

newtype OpTernary = OpTernary
  { OpTernary -> Required 1 (Enumeration TernaryKind)
kind :: Required 1 (Enumeration TernaryKind)
  } deriving stock ((forall x. OpTernary -> Rep OpTernary x)
-> (forall x. Rep OpTernary x -> OpTernary) -> Generic OpTernary
forall x. Rep OpTernary x -> OpTernary
forall x. OpTernary -> Rep OpTernary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpTernary x -> OpTernary
$cfrom :: forall x. OpTernary -> Rep OpTernary x
Generic, Int -> OpTernary -> ShowS
[OpTernary] -> ShowS
OpTernary -> String
(Int -> OpTernary -> ShowS)
-> (OpTernary -> String)
-> ([OpTernary] -> ShowS)
-> Show OpTernary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpTernary] -> ShowS
$cshowList :: [OpTernary] -> ShowS
show :: OpTernary -> String
$cshow :: OpTernary -> String
showsPrec :: Int -> OpTernary -> ShowS
$cshowsPrec :: Int -> OpTernary -> ShowS
Show)
    deriving anyclass (HashMap Tag [WireField] -> Get OpTernary
(HashMap Tag [WireField] -> Get OpTernary) -> Decode OpTernary
forall a. (HashMap Tag [WireField] -> Get a) -> Decode a
decode :: HashMap Tag [WireField] -> Get OpTernary
$cdecode :: HashMap Tag [WireField] -> Get OpTernary
Decode, OpTernary -> Put
(OpTernary -> Put) -> Encode OpTernary
forall a. (a -> Put) -> Encode a
encode :: OpTernary -> Put
$cencode :: OpTernary -> Put
Encode)

decodeBlockList :: ByteString
                -> Either String Biscuit
decodeBlockList :: ByteString -> Either String Biscuit
decodeBlockList = Get Biscuit -> ByteString -> Either String Biscuit
forall a. Get a -> ByteString -> Either String a
runGet Get Biscuit
forall a. Decode a => Get a
decodeMessage

decodeBlock :: ByteString
            -> Either String Block
decodeBlock :: ByteString -> Either String Block
decodeBlock = Get Block -> ByteString -> Either String Block
forall a. Get a -> ByteString -> Either String a
runGet Get Block
forall a. Decode a => Get a
decodeMessage

encodeBlockList :: Biscuit -> ByteString
encodeBlockList :: Biscuit -> ByteString
encodeBlockList = Put -> ByteString
runPut (Put -> ByteString) -> (Biscuit -> Put) -> Biscuit -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Biscuit -> Put
forall a. Encode a => a -> Put
encodeMessage

encodeBlock :: Block -> ByteString
encodeBlock :: Block -> ByteString
encodeBlock = Put -> ByteString
runPut (Put -> ByteString) -> (Block -> Put) -> Block -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Block -> Put
forall a. Encode a => a -> Put
encodeMessage