{-# LANGUAGE AllowAmbiguousTypes #-}
-- TK.hs: OpenPGP (RFC9580) transferable key data type
-- Copyright © 2012-2026  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module Codec.Encryption.OpenPGP.Types.Internal.TK
    ( -- * Types
      TK (..)
    , SomeTK (..)
    , TKKind (..)
    , PacketZipper (..)
    , TKKeyPkt
    , KeyringIxs
    , PublicKeyring
    , SecretKeyring
    , MixedKeyring
    , KeyringOf

      -- * Structured types
    , TKWithWireRep (..)
    , PacketRefId (..)
    , SignatureWithWireRef (..)
    , UIDWithWireRefs (..)
    , UAtWithWireRefs (..)
    , SubkeyWithWireRefs (..)
    , TKStructuredWithWireRep (..)
    , CanonicalizeTKWithWireRepError (..)

      -- * Constructors
    , mkMixedTK
    , fromPrimaryKeyPktToSomeTK

      -- * Conversions
    , someTKToMixedTK
    , someTKToPublicTK
    , someTKToSecretTK
    , someTKToPublicViewTK
    , fromMixedTKToTK
    , asMixedTK
    , tkSecretKeyPairs
    , modifyTKSecretKeys
    , TKPublicView (..)
    , TKSomes (..)
    , TKPrimaryPKPayload (..)
    , TKKeyPktToPkt (..)

      -- * Canonicalization
    , canonicalizeTKStructuredWithWireRep
    , canonicalizeTKWithWireRep
    , toStructuredTKWithWireRep

      -- * Wire representation
    , wireRepOfTK
    , wireRepsOfTK
    , packetRefsOfTK
    , packetRefIdOf
    , lookupPacketRef
    , packetWireBytesForRef
    , tksFromWireRep
    , tksContainingPacket

      -- * Sorting/comparison
    , signatureWireSortKey
    , uidWireSortKey
    , uatWireSortKey
    , subkeyWireSortKey
    , compareSignatureWithWireRefCanonical
    , compareUIDWithWireRefsCanonical
    , compareUAtWithWireRefsCanonical
    , compareSubkeyWithWireRefsCanonical
    , sortCanonicalByKey
    , sortSignatureWithWireRefsCanonical
    , sortUIDWithWireRefsCanonical
    , sortUAtWithWireRefsCanonical
    , sortSubkeyWithWireRefsCanonical

      -- * Instances
    , Eq (..)
    , Ord (..)
    , Show (..)

      -- * Lenses
    , tkPrimaryKey
    , tkRevs
    , tkDirectKeySigs
    , tkUIDs
    , tkUAts
    , tkSubs
    , tkWireRepRefs
    , tkWireRepRange
    , tkPackets
    , tkStructuredWireRepRefs
    , tkStructuredWireRepRange
    , tkStructuredPrimaryKey
    , tkStructuredPrimaryKeyRef
    , tkStructuredRevs
    , tkStructuredDirectKeySigs
    , tkStructuredUIDs
    , tkStructuredUAts
    , tkStructuredSubkeys
    , tkStructuredPacketRefs
    , signatureWithWireRefRef
    , signatureWithWireRefValue
    , uidWithWireRefsRef
    , uidWithWireRefsValue
    , uidWithWireRefsSignatures
    , uatWithWireRefsRef
    , uatWithWireRefsValue
    , uatWithWireRefsSignatures
    , subkeyWithWireRefsRef
    , subkeyWithWireRefsValue
    , subkeyWithWireRefsSignatures
    , pktWireRep
    , pktValue
    , pktIndex
    , pktRange
    , pktWireRepRef
    , zpBefore
    , zpCurrent
    , zpAfter
    , packetRefWireRepRef
    , packetRefIndex
    , rangeOffset
    , rangeLength
    ) where

import Control.Arrow ((&&&))
import Control.Comonad (Comonad (..))
import Control.Error.Util (note)
import Control.Lens
    ( makeLenses
    , (^.)
    )
import Data.Aeson (object, (.=))
import qualified Data.Aeson as A
import qualified Data.Aeson.Key as AK
import qualified Data.ByteString.Lazy as BL
import Data.Data (Data)
import Data.Function (on)
import qualified Data.HashMap.Lazy as HashMap
import Data.Hashable (Hashable)
import Data.IxSet.Typed (IxSet)
import Data.Kind (Type)
import Data.List (find, sortOn)
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Text (Text)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)

import Codec.Encryption.OpenPGP.Types.Internal.Base
import Codec.Encryption.OpenPGP.Types.Internal.Errors
import Codec.Encryption.OpenPGP.Types.Internal.PKITypes
import Codec.Encryption.OpenPGP.Types.Internal.Pkt

-- | Zipper for navigating a list of packets with position context
data PacketZipper a
    = PacketZipper
    { forall a. PacketZipper a -> [a]
_zpBefore :: [a] -- packets consumed before focus
    , forall a. PacketZipper a -> a
_zpCurrent :: a -- current packet under focus
    , forall a. PacketZipper a -> [a]
_zpAfter :: [a] -- packets remaining after focus
    }
    deriving (Typeable (PacketZipper a)
Typeable (PacketZipper a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PacketZipper a -> c (PacketZipper a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PacketZipper a))
-> (PacketZipper a -> Constr)
-> (PacketZipper a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (PacketZipper a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (PacketZipper a)))
-> ((forall b. Data b => b -> b)
    -> PacketZipper a -> PacketZipper a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> PacketZipper a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PacketZipper a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> PacketZipper a -> m (PacketZipper a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PacketZipper a -> m (PacketZipper a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PacketZipper a -> m (PacketZipper a))
-> Data (PacketZipper a)
PacketZipper a -> Constr
PacketZipper a -> DataType
(forall b. Data b => b -> b) -> PacketZipper a -> PacketZipper a
forall a. Data a => Typeable (PacketZipper a)
forall a. Data a => PacketZipper a -> Constr
forall a. Data a => PacketZipper a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> PacketZipper a -> PacketZipper a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> PacketZipper a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> PacketZipper a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PacketZipper a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketZipper a -> c (PacketZipper a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PacketZipper a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PacketZipper a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> PacketZipper a -> u
forall u. (forall d. Data d => d -> u) -> PacketZipper a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PacketZipper a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketZipper a -> c (PacketZipper a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PacketZipper a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PacketZipper a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketZipper a -> c (PacketZipper a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketZipper a -> c (PacketZipper a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PacketZipper a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PacketZipper a)
$ctoConstr :: forall a. Data a => PacketZipper a -> Constr
toConstr :: PacketZipper a -> Constr
$cdataTypeOf :: forall a. Data a => PacketZipper a -> DataType
dataTypeOf :: PacketZipper a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PacketZipper a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PacketZipper a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PacketZipper a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PacketZipper a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> PacketZipper a -> PacketZipper a
gmapT :: (forall b. Data b => b -> b) -> PacketZipper a -> PacketZipper a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketZipper a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> PacketZipper a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PacketZipper a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> PacketZipper a -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PacketZipper a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PacketZipper a -> m (PacketZipper a)
Data, PacketZipper a -> PacketZipper a -> Bool
(PacketZipper a -> PacketZipper a -> Bool)
-> (PacketZipper a -> PacketZipper a -> Bool)
-> Eq (PacketZipper a)
forall a. Eq a => PacketZipper a -> PacketZipper a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => PacketZipper a -> PacketZipper a -> Bool
== :: PacketZipper a -> PacketZipper a -> Bool
$c/= :: forall a. Eq a => PacketZipper a -> PacketZipper a -> Bool
/= :: PacketZipper a -> PacketZipper a -> Bool
Eq, (forall a b. (a -> b) -> PacketZipper a -> PacketZipper b)
-> (forall a b. a -> PacketZipper b -> PacketZipper a)
-> Functor PacketZipper
forall a b. a -> PacketZipper b -> PacketZipper a
forall a b. (a -> b) -> PacketZipper a -> PacketZipper b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> PacketZipper a -> PacketZipper b
fmap :: forall a b. (a -> b) -> PacketZipper a -> PacketZipper b
$c<$ :: forall a b. a -> PacketZipper b -> PacketZipper a
<$ :: forall a b. a -> PacketZipper b -> PacketZipper a
Functor, (forall x. PacketZipper a -> Rep (PacketZipper a) x)
-> (forall x. Rep (PacketZipper a) x -> PacketZipper a)
-> Generic (PacketZipper a)
forall x. Rep (PacketZipper a) x -> PacketZipper a
forall x. PacketZipper a -> Rep (PacketZipper a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (PacketZipper a) x -> PacketZipper a
forall a x. PacketZipper a -> Rep (PacketZipper a) x
$cfrom :: forall a x. PacketZipper a -> Rep (PacketZipper a) x
from :: forall x. PacketZipper a -> Rep (PacketZipper a) x
$cto :: forall a x. Rep (PacketZipper a) x -> PacketZipper a
to :: forall x. Rep (PacketZipper a) x -> PacketZipper a
Generic, Int -> PacketZipper a -> ShowS
[PacketZipper a] -> ShowS
PacketZipper a -> String
(Int -> PacketZipper a -> ShowS)
-> (PacketZipper a -> String)
-> ([PacketZipper a] -> ShowS)
-> Show (PacketZipper a)
forall a. Show a => Int -> PacketZipper a -> ShowS
forall a. Show a => [PacketZipper a] -> ShowS
forall a. Show a => PacketZipper a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> PacketZipper a -> ShowS
showsPrec :: Int -> PacketZipper a -> ShowS
$cshow :: forall a. Show a => PacketZipper a -> String
show :: PacketZipper a -> String
$cshowList :: forall a. Show a => [PacketZipper a] -> ShowS
showList :: [PacketZipper a] -> ShowS
Show, Typeable)

instance Comonad PacketZipper where
    -- Extract: read the packet currently under focus
    extract :: forall a. PacketZipper a -> a
extract (PacketZipper [a]
_ a
cur [a]
_) = a
cur

    -- Duplicate: produce a zipper-of-zippers,
    -- each focused on a different position in the original stream.
    duplicate :: forall a. PacketZipper a -> PacketZipper (PacketZipper a)
duplicate z :: PacketZipper a
z@(PacketZipper [a]
before a
cur [a]
after) =
        [PacketZipper a]
-> PacketZipper a
-> [PacketZipper a]
-> PacketZipper (PacketZipper a)
forall a. [a] -> a -> [a] -> PacketZipper a
PacketZipper
            [ [a] -> a -> [a] -> PacketZipper a
forall a. [a] -> a -> [a] -> PacketZipper a
PacketZipper
                (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take Int
i [a]
before)
                ([a]
before [a] -> Int -> a
forall a. HasCallStack => [a] -> Int -> a
!! Int
i)
                (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) [a]
before [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
cur] [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
after)
            | Int
i <- [Int
0 .. [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
before Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
            ]
            PacketZipper a
z
            [ [a] -> a -> [a] -> PacketZipper a
forall a. [a] -> a -> [a] -> PacketZipper a
PacketZipper
                ([a]
before [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
cur] [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take Int
i [a]
after)
                ([a]
after [a] -> Int -> a
forall a. HasCallStack => [a] -> Int -> a
!! Int
i)
                (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) [a]
after)
            | Int
i <- [Int
0 .. [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
after Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
            ]

-- | Create a zipper from a list, starting at the first element
zFromList :: [a] -> Maybe (PacketZipper a)
zFromList :: forall a. [a] -> Maybe (PacketZipper a)
zFromList [] = Maybe (PacketZipper a)
forall a. Maybe a
Nothing
zFromList (a
x : [a]
xs) = PacketZipper a -> Maybe (PacketZipper a)
forall a. a -> Maybe a
Just ([a] -> a -> [a] -> PacketZipper a
forall a. [a] -> a -> [a] -> PacketZipper a
PacketZipper [] a
x [a]
xs)

-- | Extract position in packet sequence
zPosition :: PacketZipper a -> Int
zPosition :: forall a. PacketZipper a -> Int
zPosition (PacketZipper [a]
before a
_ [a]
_) = [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
before

-- | Move to the next packet in the sequence
zMoveNext :: PacketZipper a -> Maybe (PacketZipper a)
zMoveNext :: forall a. PacketZipper a -> Maybe (PacketZipper a)
zMoveNext (PacketZipper [a]
_before a
_current []) = Maybe (PacketZipper a)
forall a. Maybe a
Nothing
zMoveNext (PacketZipper [a]
before a
current (a
x : [a]
xs)) =
    PacketZipper a -> Maybe (PacketZipper a)
forall a. a -> Maybe a
Just ([a] -> a -> [a] -> PacketZipper a
forall a. [a] -> a -> [a] -> PacketZipper a
PacketZipper ([a]
before [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
current]) a
x [a]
xs)

-- | Get the remaining packets (current + after)
zRemaining :: PacketZipper a -> [a]
zRemaining :: forall a. PacketZipper a -> [a]
zRemaining (PacketZipper [a]
_ a
current [a]
after) = a
current a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
after

-- | Reconstruct the full list from a zipper
zToList :: PacketZipper a -> [a]
zToList :: forall a. PacketZipper a -> [a]
zToList (PacketZipper [a]
before a
current [a]
after) = [a]
before [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a
current] [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
after

data TKKind
    = PublicTK
    | SecretTK
    | MixedTK
    deriving (Typeable TKKind
Typeable TKKind =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TKKind -> c TKKind)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TKKind)
-> (TKKind -> Constr)
-> (TKKind -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TKKind))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TKKind))
-> ((forall b. Data b => b -> b) -> TKKind -> TKKind)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TKKind -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TKKind -> r)
-> (forall u. (forall d. Data d => d -> u) -> TKKind -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> TKKind -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TKKind -> m TKKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TKKind -> m TKKind)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TKKind -> m TKKind)
-> Data TKKind
TKKind -> Constr
TKKind -> DataType
(forall b. Data b => b -> b) -> TKKind -> TKKind
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TKKind -> u
forall u. (forall d. Data d => d -> u) -> TKKind -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKKind
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKKind -> c TKKind
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKKind)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TKKind)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKKind -> c TKKind
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKKind -> c TKKind
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKKind
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKKind
$ctoConstr :: TKKind -> Constr
toConstr :: TKKind -> Constr
$cdataTypeOf :: TKKind -> DataType
dataTypeOf :: TKKind -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKKind)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKKind)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TKKind)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TKKind)
$cgmapT :: (forall b. Data b => b -> b) -> TKKind -> TKKind
gmapT :: (forall b. Data b => b -> b) -> TKKind -> TKKind
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TKKind -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TKKind -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TKKind -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TKKind -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TKKind -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKKind -> m TKKind
Data, TKKind -> TKKind -> Bool
(TKKind -> TKKind -> Bool)
-> (TKKind -> TKKind -> Bool) -> Eq TKKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TKKind -> TKKind -> Bool
== :: TKKind -> TKKind -> Bool
$c/= :: TKKind -> TKKind -> Bool
/= :: TKKind -> TKKind -> Bool
Eq, (forall x. TKKind -> Rep TKKind x)
-> (forall x. Rep TKKind x -> TKKind) -> Generic TKKind
forall x. Rep TKKind x -> TKKind
forall x. TKKind -> Rep TKKind x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TKKind -> Rep TKKind x
from :: forall x. TKKind -> Rep TKKind x
$cto :: forall x. Rep TKKind x -> TKKind
to :: forall x. Rep TKKind x -> TKKind
Generic, Eq TKKind
Eq TKKind =>
(TKKind -> TKKind -> Ordering)
-> (TKKind -> TKKind -> Bool)
-> (TKKind -> TKKind -> Bool)
-> (TKKind -> TKKind -> Bool)
-> (TKKind -> TKKind -> Bool)
-> (TKKind -> TKKind -> TKKind)
-> (TKKind -> TKKind -> TKKind)
-> Ord TKKind
TKKind -> TKKind -> Bool
TKKind -> TKKind -> Ordering
TKKind -> TKKind -> TKKind
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TKKind -> TKKind -> Ordering
compare :: TKKind -> TKKind -> Ordering
$c< :: TKKind -> TKKind -> Bool
< :: TKKind -> TKKind -> Bool
$c<= :: TKKind -> TKKind -> Bool
<= :: TKKind -> TKKind -> Bool
$c> :: TKKind -> TKKind -> Bool
> :: TKKind -> TKKind -> Bool
$c>= :: TKKind -> TKKind -> Bool
>= :: TKKind -> TKKind -> Bool
$cmax :: TKKind -> TKKind -> TKKind
max :: TKKind -> TKKind -> TKKind
$cmin :: TKKind -> TKKind -> TKKind
min :: TKKind -> TKKind -> TKKind
Ord, Int -> TKKind -> ShowS
[TKKind] -> ShowS
TKKind -> String
(Int -> TKKind -> ShowS)
-> (TKKind -> String) -> ([TKKind] -> ShowS) -> Show TKKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TKKind -> ShowS
showsPrec :: Int -> TKKind -> ShowS
$cshow :: TKKind -> String
show :: TKKind -> String
$cshowList :: [TKKind] -> ShowS
showList :: [TKKind] -> ShowS
Show, Typeable)

type family TKKeyPkt (k :: TKKind) :: Type where
    TKKeyPkt 'PublicTK = KeyPkt 'PublicPkt
    TKKeyPkt 'SecretTK = KeyPkt 'SecretPkt
    TKKeyPkt 'MixedTK = SomeKeyPkt

data TK (k :: TKKind)
    = TK
    { forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey :: TKKeyPkt k
    , forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs :: [SignaturePayload]
    , forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs :: [SignaturePayload]
    , forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs :: [(Text, [SignaturePayload])]
    , forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
    , forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs :: [(TKKeyPkt k, [SignaturePayload])]
    }

deriving instance Eq (TKKeyPkt k) => Eq (TK k)
deriving instance Show (TKKeyPkt k) => Show (TK k)

deriving instance
    (Data (TKKeyPkt k), Typeable k) => Data (TK k)

deriving instance (Ord (TKKeyPkt k)) => Ord (TK k)

instance A.ToJSON (TKKeyPkt k) => A.ToJSON (TK k) where
    toJSON :: TK k -> Value
toJSON TK k
tk =
        [Pair] -> Value
object
            [ String -> Key
AK.fromString String
"primaryKey" Key -> TKKeyPkt k -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> TKKeyPkt k
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK k
tk
            , String -> Key
AK.fromString String
"revs" Key -> [SignaturePayload] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK k
tk
            , String -> Key
AK.fromString String
"directKeySigs" Key -> [SignaturePayload] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK k
tk
            , String -> Key
AK.fromString String
"uids" Key -> [(Text, [SignaturePayload])] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK k
tk
            , String -> Key
AK.fromString String
"uats" Key -> [([UserAttrSubPacket], [SignaturePayload])] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK k
tk
            , String -> Key
AK.fromString String
"subs" Key -> [(TKKeyPkt k, [SignaturePayload])] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TK k -> [(TKKeyPkt k, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK k
tk
            ]

data SomeTK where
    SomePublicTK :: TK 'PublicTK -> SomeTK
    SomeSecretTK :: TK 'SecretTK -> SomeTK
    SomeMixedTK :: TK 'MixedTK -> SomeTK

deriving instance Show SomeTK

instance A.ToJSON SomeTK where
    toJSON :: SomeTK -> Value
toJSON (SomePublicTK TK 'PublicTK
tk) = TK 'PublicTK -> Value
forall a. ToJSON a => a -> Value
A.toJSON TK 'PublicTK
tk
    toJSON (SomeSecretTK TK 'SecretTK
tk) = TK 'SecretTK -> Value
forall a. ToJSON a => a -> Value
A.toJSON TK 'SecretTK
tk
    toJSON (SomeMixedTK TK 'MixedTK
tk) = TK 'MixedTK -> Value
forall a. ToJSON a => a -> Value
A.toJSON TK 'MixedTK
tk

mkMixedTK :: SomeKeyPkt -> TK 'MixedTK
mkMixedTK :: SomeKeyPkt -> TK 'MixedTK
mkMixedTK SomeKeyPkt
pkp =
    TK
        { _tkPrimaryKey :: TKKeyPkt 'MixedTK
_tkPrimaryKey = SomeKeyPkt
TKKeyPkt 'MixedTK
pkp
        , _tkRevs :: [SignaturePayload]
_tkRevs = []
        , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = []
        , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = []
        , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = []
        , _tkSubs :: [(TKKeyPkt 'MixedTK, [SignaturePayload])]
_tkSubs = []
        }

fromPrimaryKeyPktToSomeTK
    :: Pkt -> Either TKConversionError SomeTK
fromPrimaryKeyPktToSomeTK :: Pkt -> Either TKConversionError SomeTK
fromPrimaryKeyPktToSomeTK (PublicKeyPkt SomePKPayload
pkp) =
    SomeTK -> Either TKConversionError SomeTK
forall a b. b -> Either a b
Right
        ( TK 'PublicTK -> SomeTK
SomePublicTK
            ( TK
                { _tkPrimaryKey :: TKKeyPkt 'PublicTK
_tkPrimaryKey = SomePKPayload -> KeyPkt 'PublicPkt
KeyPktPublicPrimary SomePKPayload
pkp
                , _tkRevs :: [SignaturePayload]
_tkRevs = []
                , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = []
                , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = []
                , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = []
                , _tkSubs :: [(TKKeyPkt 'PublicTK, [SignaturePayload])]
_tkSubs = []
                }
            )
        )
fromPrimaryKeyPktToSomeTK (SecretKeyPkt SomePKPayload
pkp SKAddendum
ska) =
    SomeTK -> Either TKConversionError SomeTK
forall a b. b -> Either a b
Right
        ( TK 'SecretTK -> SomeTK
SomeSecretTK
            ( TK
                { _tkPrimaryKey :: TKKeyPkt 'SecretTK
_tkPrimaryKey = SomePKPayload -> SKAddendum -> KeyPkt 'SecretPkt
KeyPktSecretPrimary SomePKPayload
pkp SKAddendum
ska
                , _tkRevs :: [SignaturePayload]
_tkRevs = []
                , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = []
                , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = []
                , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = []
                , _tkSubs :: [(TKKeyPkt 'SecretTK, [SignaturePayload])]
_tkSubs = []
                }
            )
        )
fromPrimaryKeyPktToSomeTK (PublicSubkeyPkt SomePKPayload
_) =
    TKConversionError -> Either TKConversionError SomeTK
forall a b. a -> Either a b
Left TKConversionError
PublicSubkeyHasPrimaryRole
fromPrimaryKeyPktToSomeTK (SecretSubkeyPkt SomePKPayload
_ SKAddendum
_) =
    TKConversionError -> Either TKConversionError SomeTK
forall a b. a -> Either a b
Left TKConversionError
SecretSubkeyHasPrimaryRole
fromPrimaryKeyPktToSomeTK Pkt
pkt =
    TKConversionError -> Either TKConversionError SomeTK
forall a b. a -> Either a b
Left (Word8 -> TKConversionError
ExpectedPublicPrimaryKeyPacket (Pkt -> Word8
pktTag Pkt
pkt))

someTKToPublicTK :: SomeTK -> Maybe (TK 'PublicTK)
someTKToPublicTK :: SomeTK -> Maybe (TK 'PublicTK)
someTKToPublicTK (SomePublicTK TK 'PublicTK
tk) = TK 'PublicTK -> Maybe (TK 'PublicTK)
forall a. a -> Maybe a
Just TK 'PublicTK
tk
someTKToPublicTK (SomeSecretTK TK 'SecretTK
_) = Maybe (TK 'PublicTK)
forall a. Maybe a
Nothing
someTKToPublicTK (SomeMixedTK TK 'MixedTK
_) = Maybe (TK 'PublicTK)
forall a. Maybe a
Nothing

someTKToSecretTK :: SomeTK -> Maybe (TK 'SecretTK)
someTKToSecretTK :: SomeTK -> Maybe (TK 'SecretTK)
someTKToSecretTK (SomeSecretTK TK 'SecretTK
tk) = TK 'SecretTK -> Maybe (TK 'SecretTK)
forall a. a -> Maybe a
Just TK 'SecretTK
tk
someTKToSecretTK (SomePublicTK TK 'PublicTK
_) = Maybe (TK 'SecretTK)
forall a. Maybe a
Nothing
someTKToSecretTK (SomeMixedTK TK 'MixedTK
_) = Maybe (TK 'SecretTK)
forall a. Maybe a
Nothing

someTKToPublicViewTK :: SomeTK -> TK 'PublicTK
someTKToPublicViewTK :: SomeTK -> TK 'PublicTK
someTKToPublicViewTK (SomePublicTK TK 'PublicTK
tk) = TK 'PublicTK
tk
someTKToPublicViewTK (SomeSecretTK TK 'SecretTK
tk) = TK 'SecretTK -> TK 'PublicTK
forall (k :: TKKind). TKPublicView k => TK k -> TK 'PublicTK
publicViewTK TK 'SecretTK
tk
someTKToPublicViewTK (SomeMixedTK TK 'MixedTK
tk) = TK 'MixedTK -> TK 'PublicTK
forall (k :: TKKind). TKPublicView k => TK k -> TK 'PublicTK
publicViewTK TK 'MixedTK
tk

someTKToMixedTK :: SomeTK -> Maybe (TK 'MixedTK)
someTKToMixedTK :: SomeTK -> Maybe (TK 'MixedTK)
someTKToMixedTK (SomeMixedTK TK 'MixedTK
tk) = TK 'MixedTK -> Maybe (TK 'MixedTK)
forall a. a -> Maybe a
Just TK 'MixedTK
tk
someTKToMixedTK SomeTK
_ = Maybe (TK 'MixedTK)
forall a. Maybe a
Nothing

class TKPublicView (k :: TKKind) where
    publicViewTK :: TK k -> TK 'PublicTK

instance TKPublicView 'PublicTK where
    publicViewTK :: TK 'PublicTK -> TK 'PublicTK
publicViewTK TK 'PublicTK
tk = TK 'PublicTK
tk

instance TKPublicView 'SecretTK where
    publicViewTK :: TK 'SecretTK -> TK 'PublicTK
publicViewTK TK 'SecretTK
tk =
        TK
            { _tkPrimaryKey :: TKKeyPkt 'PublicTK
_tkPrimaryKey = KeyPkt 'SecretPkt -> KeyPkt 'PublicPkt
keyPktToPublicView (TK 'SecretTK -> TKKeyPkt 'SecretTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'SecretTK
tk)
            , _tkRevs :: [SignaturePayload]
_tkRevs = TK 'SecretTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK 'SecretTK
tk
            , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = TK 'SecretTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK 'SecretTK
tk
            , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = TK 'SecretTK -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK 'SecretTK
tk
            , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = TK 'SecretTK -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK 'SecretTK
tk
            , _tkSubs :: [(TKKeyPkt 'PublicTK, [SignaturePayload])]
_tkSubs =
                ((KeyPkt 'SecretPkt, [SignaturePayload])
 -> (KeyPkt 'PublicPkt, [SignaturePayload]))
-> [(KeyPkt 'SecretPkt, [SignaturePayload])]
-> [(KeyPkt 'PublicPkt, [SignaturePayload])]
forall a b. (a -> b) -> [a] -> [b]
map
                    ( \(KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs) ->
                        (KeyPkt 'SecretPkt -> KeyPkt 'PublicPkt
keyPktToPublicView KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs)
                    )
                    (TK 'SecretTK -> [(TKKeyPkt 'SecretTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'SecretTK
tk)
            }

instance TKPublicView 'MixedTK where
    publicViewTK :: TK 'MixedTK -> TK 'PublicTK
publicViewTK TK 'MixedTK
tk =
        TK
            { _tkPrimaryKey :: TKKeyPkt 'PublicTK
_tkPrimaryKey =
                SomeKeyPkt -> KeyPkt 'PublicPkt
someKeyPktToPublicPkt (SomeKeyPkt -> SomeKeyPkt
forall a. KeyPktToSomeKeyPkt a => a -> SomeKeyPkt
toSomeKeyPkt (TK 'MixedTK -> TKKeyPkt 'MixedTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'MixedTK
tk))
            , _tkRevs :: [SignaturePayload]
_tkRevs = TK 'MixedTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK 'MixedTK
tk
            , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = TK 'MixedTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK 'MixedTK
tk
            , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = TK 'MixedTK -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK 'MixedTK
tk
            , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = TK 'MixedTK -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK 'MixedTK
tk
            , _tkSubs :: [(TKKeyPkt 'PublicTK, [SignaturePayload])]
_tkSubs =
                ((SomeKeyPkt, [SignaturePayload])
 -> (KeyPkt 'PublicPkt, [SignaturePayload]))
-> [(SomeKeyPkt, [SignaturePayload])]
-> [(KeyPkt 'PublicPkt, [SignaturePayload])]
forall a b. (a -> b) -> [a] -> [b]
map
                    ( \(SomeKeyPkt
kp, [SignaturePayload]
sigs) ->
                        (SomeKeyPkt -> KeyPkt 'PublicPkt
someKeyPktToPublicPkt (SomeKeyPkt -> SomeKeyPkt
forall a. KeyPktToSomeKeyPkt a => a -> SomeKeyPkt
toSomeKeyPkt SomeKeyPkt
kp), [SignaturePayload]
sigs)
                    )
                    (TK 'MixedTK -> [(TKKeyPkt 'MixedTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'MixedTK
tk)
            }

class TKSomes (k :: TKKind) where
    tkSomeSubs :: TK k -> [SomeKeyPkt]

instance TKSomes 'PublicTK where
    tkSomeSubs :: TK 'PublicTK -> [SomeKeyPkt]
tkSomeSubs TK 'PublicTK
tk =
        KeyPkt 'PublicPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt (TK 'PublicTK -> TKKeyPkt 'PublicTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'PublicTK
tk)
            SomeKeyPkt -> [SomeKeyPkt] -> [SomeKeyPkt]
forall a. a -> [a] -> [a]
: [KeyPkt 'PublicPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt KeyPkt 'PublicPkt
kp | (KeyPkt 'PublicPkt
kp, [SignaturePayload]
_) <- TK 'PublicTK -> [(TKKeyPkt 'PublicTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'PublicTK
tk]

instance TKSomes 'SecretTK where
    tkSomeSubs :: TK 'SecretTK -> [SomeKeyPkt]
tkSomeSubs TK 'SecretTK
tk =
        KeyPkt 'SecretPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt (TK 'SecretTK -> TKKeyPkt 'SecretTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'SecretTK
tk)
            SomeKeyPkt -> [SomeKeyPkt] -> [SomeKeyPkt]
forall a. a -> [a] -> [a]
: [KeyPkt 'SecretPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt KeyPkt 'SecretPkt
kp | (KeyPkt 'SecretPkt
kp, [SignaturePayload]
_) <- TK 'SecretTK -> [(TKKeyPkt 'SecretTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'SecretTK
tk]

instance TKSomes 'MixedTK where
    tkSomeSubs :: TK 'MixedTK -> [SomeKeyPkt]
tkSomeSubs TK 'MixedTK
tk = TK 'MixedTK -> TKKeyPkt 'MixedTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'MixedTK
tk SomeKeyPkt -> [SomeKeyPkt] -> [SomeKeyPkt]
forall a. a -> [a] -> [a]
: [SomeKeyPkt
kp | (SomeKeyPkt
kp, [SignaturePayload]
_) <- TK 'MixedTK -> [(TKKeyPkt 'MixedTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'MixedTK
tk]

tkSecretKeyPairs :: TK 'SecretTK -> [(SomePKPayload, SKAddendum)]
tkSecretKeyPairs :: TK 'SecretTK -> [(SomePKPayload, SKAddendum)]
tkSecretKeyPairs TK 'SecretTK
tk =
    [ (KeyPkt 'SecretPkt -> SomePKPayload
forall (k :: KeyPktKind). KeyPkt k -> SomePKPayload
keyPktPKPayload KeyPkt 'SecretPkt
kp, KeyPkt 'SecretPkt -> SKAddendum
secretKeyPktSKAddendum KeyPkt 'SecretPkt
kp)
    | KeyPkt 'SecretPkt
kp <- TK 'SecretTK -> TKKeyPkt 'SecretTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'SecretTK
tk KeyPkt 'SecretPkt -> [KeyPkt 'SecretPkt] -> [KeyPkt 'SecretPkt]
forall a. a -> [a] -> [a]
: ((KeyPkt 'SecretPkt, [SignaturePayload]) -> KeyPkt 'SecretPkt)
-> [(KeyPkt 'SecretPkt, [SignaturePayload])] -> [KeyPkt 'SecretPkt]
forall a b. (a -> b) -> [a] -> [b]
map (KeyPkt 'SecretPkt, [SignaturePayload]) -> KeyPkt 'SecretPkt
forall a b. (a, b) -> a
fst (TK 'SecretTK -> [(TKKeyPkt 'SecretTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'SecretTK
tk)
    ]

class TKPrimaryPKPayload (k :: TKKind) where
    tkPrimaryPKPayload :: TK k -> SomePKPayload

instance TKPrimaryPKPayload 'PublicTK where
    tkPrimaryPKPayload :: TK 'PublicTK -> SomePKPayload
tkPrimaryPKPayload TK 'PublicTK
tk = KeyPkt 'PublicPkt -> SomePKPayload
forall (k :: KeyPktKind). KeyPkt k -> SomePKPayload
keyPktPKPayload (TK 'PublicTK -> TKKeyPkt 'PublicTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'PublicTK
tk)

instance TKPrimaryPKPayload 'SecretTK where
    tkPrimaryPKPayload :: TK 'SecretTK -> SomePKPayload
tkPrimaryPKPayload TK 'SecretTK
tk = KeyPkt 'SecretPkt -> SomePKPayload
forall (k :: KeyPktKind). KeyPkt k -> SomePKPayload
keyPktPKPayload (TK 'SecretTK -> TKKeyPkt 'SecretTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'SecretTK
tk)

instance TKPrimaryPKPayload 'MixedTK where
    tkPrimaryPKPayload :: TK 'MixedTK -> SomePKPayload
tkPrimaryPKPayload TK 'MixedTK
tk = SomeKeyPkt -> SomePKPayload
someKeyPktPKPayload (TK 'MixedTK -> TKKeyPkt 'MixedTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'MixedTK
tk)

class TKKeyPktToPkt (k :: TKKind) where
    tkKeyPktToPkt :: TKKeyPkt k -> Pkt

instance TKKeyPktToPkt 'PublicTK where
    tkKeyPktToPkt :: TKKeyPkt 'PublicTK -> Pkt
tkKeyPktToPkt = KeyPkt 'PublicPkt -> Pkt
TKKeyPkt 'PublicTK -> Pkt
forall (k :: KeyPktKind). KeyPkt k -> Pkt
keyPktToPkt

instance TKKeyPktToPkt 'SecretTK where
    tkKeyPktToPkt :: TKKeyPkt 'SecretTK -> Pkt
tkKeyPktToPkt = KeyPkt 'SecretPkt -> Pkt
TKKeyPkt 'SecretTK -> Pkt
forall (k :: KeyPktKind). KeyPkt k -> Pkt
keyPktToPkt

instance TKKeyPktToPkt 'MixedTK where
    tkKeyPktToPkt :: TKKeyPkt 'MixedTK -> Pkt
tkKeyPktToPkt (SomeKeyPkt KeyPkt k
kp) = KeyPkt k -> Pkt
forall (k :: KeyPktKind). KeyPkt k -> Pkt
keyPktToPkt KeyPkt k
kp

modifyTKSecretKeys
    :: TK 'SecretTK
    -> (SomePKPayload -> SKAddendum -> (SomePKPayload, SKAddendum))
    -> TK 'SecretTK
modifyTKSecretKeys :: TK 'SecretTK
-> (SomePKPayload -> SKAddendum -> (SomePKPayload, SKAddendum))
-> TK 'SecretTK
modifyTKSecretKeys TK 'SecretTK
tk SomePKPayload -> SKAddendum -> (SomePKPayload, SKAddendum)
f =
    TK 'SecretTK
tk
        { _tkPrimaryKey = go (_tkPrimaryKey tk)
        , _tkSubs =
            map
                ( \(KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs) ->
                    (KeyPkt 'SecretPkt -> KeyPkt 'SecretPkt
go KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs)
                )
                (_tkSubs tk)
        }
  where
    go :: KeyPkt 'SecretPkt -> KeyPkt 'SecretPkt
    go :: KeyPkt 'SecretPkt -> KeyPkt 'SecretPkt
go (KeyPktSecretPrimary SomePKPayload
pkp SKAddendum
ska) =
        let (SomePKPayload
pkp', SKAddendum
ska') = SomePKPayload -> SKAddendum -> (SomePKPayload, SKAddendum)
f SomePKPayload
pkp SKAddendum
ska
         in SomePKPayload -> SKAddendum -> KeyPkt 'SecretPkt
KeyPktSecretPrimary SomePKPayload
pkp' SKAddendum
ska'
    go (KeyPktSecretSubkey SomePKPayload
pkp SKAddendum
ska) =
        let (SomePKPayload
pkp', SKAddendum
ska') = SomePKPayload -> SKAddendum -> (SomePKPayload, SKAddendum)
f SomePKPayload
pkp SKAddendum
ska
         in SomePKPayload -> SKAddendum -> KeyPkt 'SecretPkt
KeyPktSecretSubkey SomePKPayload
pkp' SKAddendum
ska'

fromMixedTKToTK :: TK 'MixedTK -> SomeTK
fromMixedTKToTK :: TK 'MixedTK -> SomeTK
fromMixedTKToTK = TK 'MixedTK -> SomeTK
SomeMixedTK

asMixedTK :: SomeTK -> TK 'MixedTK
asMixedTK :: SomeTK -> TK 'MixedTK
asMixedTK (SomePublicTK TK 'PublicTK
tk) =
    TK
        { _tkPrimaryKey :: TKKeyPkt 'MixedTK
_tkPrimaryKey = KeyPkt 'PublicPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt (TK 'PublicTK -> TKKeyPkt 'PublicTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'PublicTK
tk)
        , _tkRevs :: [SignaturePayload]
_tkRevs = TK 'PublicTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK 'PublicTK
tk
        , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = TK 'PublicTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK 'PublicTK
tk
        , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = TK 'PublicTK -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK 'PublicTK
tk
        , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = TK 'PublicTK -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK 'PublicTK
tk
        , _tkSubs :: [(TKKeyPkt 'MixedTK, [SignaturePayload])]
_tkSubs = [(KeyPkt 'PublicPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt KeyPkt 'PublicPkt
kp, [SignaturePayload]
sigs) | (KeyPkt 'PublicPkt
kp, [SignaturePayload]
sigs) <- TK 'PublicTK -> [(TKKeyPkt 'PublicTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'PublicTK
tk]
        }
asMixedTK (SomeSecretTK TK 'SecretTK
tk) =
    TK
        { _tkPrimaryKey :: TKKeyPkt 'MixedTK
_tkPrimaryKey = KeyPkt 'SecretPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt (TK 'SecretTK -> TKKeyPkt 'SecretTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'SecretTK
tk)
        , _tkRevs :: [SignaturePayload]
_tkRevs = TK 'SecretTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK 'SecretTK
tk
        , _tkDirectKeySigs :: [SignaturePayload]
_tkDirectKeySigs = TK 'SecretTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK 'SecretTK
tk
        , _tkUIDs :: [(Text, [SignaturePayload])]
_tkUIDs = TK 'SecretTK -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK 'SecretTK
tk
        , _tkUAts :: [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts = TK 'SecretTK -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK 'SecretTK
tk
        , _tkSubs :: [(TKKeyPkt 'MixedTK, [SignaturePayload])]
_tkSubs = [(KeyPkt 'SecretPkt -> SomeKeyPkt
forall (k :: KeyPktKind). KeyPkt k -> SomeKeyPkt
SomeKeyPkt KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs) | (KeyPkt 'SecretPkt
kp, [SignaturePayload]
sigs) <- TK 'SecretTK -> [(TKKeyPkt 'SecretTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'SecretTK
tk]
        }
asMixedTK (SomeMixedTK TK 'MixedTK
tk) = TK 'MixedTK
tk

instance Eq SomeTK where
    SomeTK
a == :: SomeTK -> SomeTK -> Bool
== SomeTK
b = SomeTK -> TK 'MixedTK
asMixedTK SomeTK
a TK 'MixedTK -> TK 'MixedTK -> Bool
forall a. Eq a => a -> a -> Bool
== SomeTK -> TK 'MixedTK
asMixedTK SomeTK
b

instance Semigroup SomeTK where
    SomePublicTK TK 'PublicTK
a <> :: SomeTK -> SomeTK -> SomeTK
<> SomePublicTK TK 'PublicTK
b = TK 'PublicTK -> SomeTK
SomePublicTK (TK 'PublicTK
a TK 'PublicTK -> TK 'PublicTK -> TK 'PublicTK
forall a. Semigroup a => a -> a -> a
<> TK 'PublicTK
b)
    SomeSecretTK TK 'SecretTK
a <> SomeSecretTK TK 'SecretTK
b = TK 'SecretTK -> SomeTK
SomeSecretTK (TK 'SecretTK
a TK 'SecretTK -> TK 'SecretTK -> TK 'SecretTK
forall a. Semigroup a => a -> a -> a
<> TK 'SecretTK
b)
    SomeMixedTK TK 'MixedTK
a <> SomeMixedTK TK 'MixedTK
b = TK 'MixedTK -> SomeTK
SomeMixedTK (TK 'MixedTK
a TK 'MixedTK -> TK 'MixedTK -> TK 'MixedTK
forall a. Semigroup a => a -> a -> a
<> TK 'MixedTK
b)
    SomeTK
a <> SomeTK
b = TK 'MixedTK -> SomeTK
SomeMixedTK (SomeTK -> TK 'MixedTK
asMixedTK SomeTK
a TK 'MixedTK -> TK 'MixedTK -> TK 'MixedTK
forall a. Semigroup a => a -> a -> a
<> SomeTK -> TK 'MixedTK
asMixedTK SomeTK
b)

instance (Hashable (TKKeyPkt k), Ord (TKKeyPkt k)) => Semigroup (TK k) where
    TK k
a <> :: TK k -> TK k -> TK k
<> TK k
b =
        TKKeyPkt k
-> [SignaturePayload]
-> [SignaturePayload]
-> [(Text, [SignaturePayload])]
-> [([UserAttrSubPacket], [SignaturePayload])]
-> [(TKKeyPkt k, [SignaturePayload])]
-> TK k
forall (k :: TKKind).
TKKeyPkt k
-> [SignaturePayload]
-> [SignaturePayload]
-> [(Text, [SignaturePayload])]
-> [([UserAttrSubPacket], [SignaturePayload])]
-> [(TKKeyPkt k, [SignaturePayload])]
-> TK k
TK
            (TK k -> TKKeyPkt k
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK k
a)
            ( Set SignaturePayload -> [SignaturePayload]
forall a. Set a -> [a]
Set.toList (Set SignaturePayload -> [SignaturePayload])
-> Set SignaturePayload -> [SignaturePayload]
forall a b. (a -> b) -> a -> b
$
                Set SignaturePayload
-> Set SignaturePayload -> Set SignaturePayload
forall a. Ord a => Set a -> Set a -> Set a
Set.union ([SignaturePayload] -> Set SignaturePayload
forall a. Ord a => [a] -> Set a
Set.fromList (TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK k
a)) ([SignaturePayload] -> Set SignaturePayload
forall a. Ord a => [a] -> Set a
Set.fromList (TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK k
b))
            )
            ( Set SignaturePayload -> [SignaturePayload]
forall a. Set a -> [a]
Set.toList (Set SignaturePayload -> [SignaturePayload])
-> Set SignaturePayload -> [SignaturePayload]
forall a b. (a -> b) -> a -> b
$
                Set SignaturePayload
-> Set SignaturePayload -> Set SignaturePayload
forall a. Ord a => Set a -> Set a -> Set a
Set.union
                    ([SignaturePayload] -> Set SignaturePayload
forall a. Ord a => [a] -> Set a
Set.fromList (TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK k
a))
                    ([SignaturePayload] -> Set SignaturePayload
forall a. Ord a => [a] -> Set a
Set.fromList (TK k -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK k
b))
            )
            (([(Text, [SignaturePayload])]
-> [(Text, [SignaturePayload])] -> [(Text, [SignaturePayload])]
forall {k} {a}.
(Ord k, Ord a) =>
[(k, [a])] -> [(k, [a])] -> [(k, [a])]
kvmerge ([(Text, [SignaturePayload])]
 -> [(Text, [SignaturePayload])] -> [(Text, [SignaturePayload])])
-> (TK k -> [(Text, [SignaturePayload])])
-> TK k
-> TK k
-> [(Text, [SignaturePayload])]
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TK k -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs) TK k
a TK k
b)
            (([([UserAttrSubPacket], [SignaturePayload])]
-> [([UserAttrSubPacket], [SignaturePayload])]
-> [([UserAttrSubPacket], [SignaturePayload])]
forall {k} {a}.
(Ord k, Ord a) =>
[(k, [a])] -> [(k, [a])] -> [(k, [a])]
kvmerge ([([UserAttrSubPacket], [SignaturePayload])]
 -> [([UserAttrSubPacket], [SignaturePayload])]
 -> [([UserAttrSubPacket], [SignaturePayload])])
-> (TK k -> [([UserAttrSubPacket], [SignaturePayload])])
-> TK k
-> TK k
-> [([UserAttrSubPacket], [SignaturePayload])]
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TK k -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts) TK k
a TK k
b)
            (([(TKKeyPkt k, [SignaturePayload])]
-> [(TKKeyPkt k, [SignaturePayload])]
-> [(TKKeyPkt k, [SignaturePayload])]
forall {a} {k}.
(Ord a, Hashable k) =>
[(k, [a])] -> [(k, [a])] -> [(k, [a])]
ukvmerge ([(TKKeyPkt k, [SignaturePayload])]
 -> [(TKKeyPkt k, [SignaturePayload])]
 -> [(TKKeyPkt k, [SignaturePayload])])
-> (TK k -> [(TKKeyPkt k, [SignaturePayload])])
-> TK k
-> TK k
-> [(TKKeyPkt k, [SignaturePayload])]
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TK k -> [(TKKeyPkt k, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs) TK k
a TK k
b)
      where
        kvmerge :: [(k, [a])] -> [(k, [a])] -> [(k, [a])]
kvmerge [(k, [a])]
x [(k, [a])]
y =
            Map k [a] -> [(k, [a])]
forall k a. Map k a -> [(k, a)]
Map.toList (([a] -> [a] -> [a]) -> Map k [a] -> Map k [a] -> Map k [a]
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith [a] -> [a] -> [a]
forall {a}. Ord a => [a] -> [a] -> [a]
nsa ([(k, [a])] -> Map k [a]
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(k, [a])]
x) ([(k, [a])] -> Map k [a]
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(k, [a])]
y))
        ukvmerge :: [(k, [a])] -> [(k, [a])] -> [(k, [a])]
ukvmerge [(k, [a])]
x [(k, [a])]
y =
            HashMap k [a] -> [(k, [a])]
forall k v. HashMap k v -> [(k, v)]
HashMap.toList
                (([a] -> [a] -> [a])
-> HashMap k [a] -> HashMap k [a] -> HashMap k [a]
forall k v.
Eq k =>
(v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v
HashMap.unionWith [a] -> [a] -> [a]
forall {a}. Ord a => [a] -> [a] -> [a]
nsa ([(k, [a])] -> HashMap k [a]
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList [(k, [a])]
x) ([(k, [a])] -> HashMap k [a]
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList [(k, [a])]
y))
        nsa :: [a] -> [a] -> [a]
nsa [a]
x [a]
y = Set a -> [a]
forall a. Set a -> [a]
Set.toList (Set a -> [a]) -> Set a -> [a]
forall a b. (a -> b) -> a -> b
$ Set a -> Set a -> Set a
forall a. Ord a => Set a -> Set a -> Set a
Set.union ([a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList [a]
x) ([a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList [a]
y)

data TKWithWireRep
    = TKWithWireRep
    { TKWithWireRep -> WireRepRefs
_tkWireRepRefs :: WireRepRefs
    , TKWithWireRep -> Maybe ByteRange
_tkWireRepRange :: Maybe ByteRange
    , TKWithWireRep -> [PktWithWireRep]
_tkPackets :: [PktWithWireRep]
    , TKWithWireRep -> TK 'MixedTK
_tkValue :: TK 'MixedTK
    }
    deriving (Typeable TKWithWireRep
Typeable TKWithWireRep =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TKWithWireRep -> c TKWithWireRep)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TKWithWireRep)
-> (TKWithWireRep -> Constr)
-> (TKWithWireRep -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TKWithWireRep))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c TKWithWireRep))
-> ((forall b. Data b => b -> b) -> TKWithWireRep -> TKWithWireRep)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r)
-> (forall u. (forall d. Data d => d -> u) -> TKWithWireRep -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TKWithWireRep -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep)
-> Data TKWithWireRep
TKWithWireRep -> Constr
TKWithWireRep -> DataType
(forall b. Data b => b -> b) -> TKWithWireRep -> TKWithWireRep
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> TKWithWireRep -> u
forall u. (forall d. Data d => d -> u) -> TKWithWireRep -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKWithWireRep
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKWithWireRep -> c TKWithWireRep
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKWithWireRep)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKWithWireRep)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKWithWireRep -> c TKWithWireRep
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TKWithWireRep -> c TKWithWireRep
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKWithWireRep
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKWithWireRep
$ctoConstr :: TKWithWireRep -> Constr
toConstr :: TKWithWireRep -> Constr
$cdataTypeOf :: TKWithWireRep -> DataType
dataTypeOf :: TKWithWireRep -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKWithWireRep)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKWithWireRep)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKWithWireRep)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKWithWireRep)
$cgmapT :: (forall b. Data b => b -> b) -> TKWithWireRep -> TKWithWireRep
gmapT :: (forall b. Data b => b -> b) -> TKWithWireRep -> TKWithWireRep
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TKWithWireRep -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TKWithWireRep -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TKWithWireRep -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TKWithWireRep -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TKWithWireRep -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TKWithWireRep -> m TKWithWireRep
Data, TKWithWireRep -> TKWithWireRep -> Bool
(TKWithWireRep -> TKWithWireRep -> Bool)
-> (TKWithWireRep -> TKWithWireRep -> Bool) -> Eq TKWithWireRep
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TKWithWireRep -> TKWithWireRep -> Bool
== :: TKWithWireRep -> TKWithWireRep -> Bool
$c/= :: TKWithWireRep -> TKWithWireRep -> Bool
/= :: TKWithWireRep -> TKWithWireRep -> Bool
Eq, (forall x. TKWithWireRep -> Rep TKWithWireRep x)
-> (forall x. Rep TKWithWireRep x -> TKWithWireRep)
-> Generic TKWithWireRep
forall x. Rep TKWithWireRep x -> TKWithWireRep
forall x. TKWithWireRep -> Rep TKWithWireRep x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TKWithWireRep -> Rep TKWithWireRep x
from :: forall x. TKWithWireRep -> Rep TKWithWireRep x
$cto :: forall x. Rep TKWithWireRep x -> TKWithWireRep
to :: forall x. Rep TKWithWireRep x -> TKWithWireRep
Generic, Eq TKWithWireRep
Eq TKWithWireRep =>
(TKWithWireRep -> TKWithWireRep -> Ordering)
-> (TKWithWireRep -> TKWithWireRep -> Bool)
-> (TKWithWireRep -> TKWithWireRep -> Bool)
-> (TKWithWireRep -> TKWithWireRep -> Bool)
-> (TKWithWireRep -> TKWithWireRep -> Bool)
-> (TKWithWireRep -> TKWithWireRep -> TKWithWireRep)
-> (TKWithWireRep -> TKWithWireRep -> TKWithWireRep)
-> Ord TKWithWireRep
TKWithWireRep -> TKWithWireRep -> Bool
TKWithWireRep -> TKWithWireRep -> Ordering
TKWithWireRep -> TKWithWireRep -> TKWithWireRep
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TKWithWireRep -> TKWithWireRep -> Ordering
compare :: TKWithWireRep -> TKWithWireRep -> Ordering
$c< :: TKWithWireRep -> TKWithWireRep -> Bool
< :: TKWithWireRep -> TKWithWireRep -> Bool
$c<= :: TKWithWireRep -> TKWithWireRep -> Bool
<= :: TKWithWireRep -> TKWithWireRep -> Bool
$c> :: TKWithWireRep -> TKWithWireRep -> Bool
> :: TKWithWireRep -> TKWithWireRep -> Bool
$c>= :: TKWithWireRep -> TKWithWireRep -> Bool
>= :: TKWithWireRep -> TKWithWireRep -> Bool
$cmax :: TKWithWireRep -> TKWithWireRep -> TKWithWireRep
max :: TKWithWireRep -> TKWithWireRep -> TKWithWireRep
$cmin :: TKWithWireRep -> TKWithWireRep -> TKWithWireRep
min :: TKWithWireRep -> TKWithWireRep -> TKWithWireRep
Ord, Int -> TKWithWireRep -> ShowS
[TKWithWireRep] -> ShowS
TKWithWireRep -> String
(Int -> TKWithWireRep -> ShowS)
-> (TKWithWireRep -> String)
-> ([TKWithWireRep] -> ShowS)
-> Show TKWithWireRep
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TKWithWireRep -> ShowS
showsPrec :: Int -> TKWithWireRep -> ShowS
$cshow :: TKWithWireRep -> String
show :: TKWithWireRep -> String
$cshowList :: [TKWithWireRep] -> ShowS
showList :: [TKWithWireRep] -> ShowS
Show, Typeable)

data PacketRefId
    = PacketRefId
    { PacketRefId -> WireRepRef
_packetRefWireRepRef :: WireRepRef
    , PacketRefId -> Int
_packetRefIndex :: Int
    }
    deriving (Typeable PacketRefId
Typeable PacketRefId =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PacketRefId -> c PacketRefId)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PacketRefId)
-> (PacketRefId -> Constr)
-> (PacketRefId -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PacketRefId))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PacketRefId))
-> ((forall b. Data b => b -> b) -> PacketRefId -> PacketRefId)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PacketRefId -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PacketRefId -> r)
-> (forall u. (forall d. Data d => d -> u) -> PacketRefId -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PacketRefId -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId)
-> Data PacketRefId
PacketRefId -> Constr
PacketRefId -> DataType
(forall b. Data b => b -> b) -> PacketRefId -> PacketRefId
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PacketRefId -> u
forall u. (forall d. Data d => d -> u) -> PacketRefId -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PacketRefId
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketRefId -> c PacketRefId
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PacketRefId)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PacketRefId)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketRefId -> c PacketRefId
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PacketRefId -> c PacketRefId
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PacketRefId
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PacketRefId
$ctoConstr :: PacketRefId -> Constr
toConstr :: PacketRefId -> Constr
$cdataTypeOf :: PacketRefId -> DataType
dataTypeOf :: PacketRefId -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PacketRefId)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PacketRefId)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PacketRefId)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PacketRefId)
$cgmapT :: (forall b. Data b => b -> b) -> PacketRefId -> PacketRefId
gmapT :: (forall b. Data b => b -> b) -> PacketRefId -> PacketRefId
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PacketRefId -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PacketRefId -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PacketRefId -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PacketRefId -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PacketRefId -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PacketRefId -> m PacketRefId
Data, PacketRefId -> PacketRefId -> Bool
(PacketRefId -> PacketRefId -> Bool)
-> (PacketRefId -> PacketRefId -> Bool) -> Eq PacketRefId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PacketRefId -> PacketRefId -> Bool
== :: PacketRefId -> PacketRefId -> Bool
$c/= :: PacketRefId -> PacketRefId -> Bool
/= :: PacketRefId -> PacketRefId -> Bool
Eq, (forall x. PacketRefId -> Rep PacketRefId x)
-> (forall x. Rep PacketRefId x -> PacketRefId)
-> Generic PacketRefId
forall x. Rep PacketRefId x -> PacketRefId
forall x. PacketRefId -> Rep PacketRefId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PacketRefId -> Rep PacketRefId x
from :: forall x. PacketRefId -> Rep PacketRefId x
$cto :: forall x. Rep PacketRefId x -> PacketRefId
to :: forall x. Rep PacketRefId x -> PacketRefId
Generic, Eq PacketRefId
Eq PacketRefId =>
(PacketRefId -> PacketRefId -> Ordering)
-> (PacketRefId -> PacketRefId -> Bool)
-> (PacketRefId -> PacketRefId -> Bool)
-> (PacketRefId -> PacketRefId -> Bool)
-> (PacketRefId -> PacketRefId -> Bool)
-> (PacketRefId -> PacketRefId -> PacketRefId)
-> (PacketRefId -> PacketRefId -> PacketRefId)
-> Ord PacketRefId
PacketRefId -> PacketRefId -> Bool
PacketRefId -> PacketRefId -> Ordering
PacketRefId -> PacketRefId -> PacketRefId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PacketRefId -> PacketRefId -> Ordering
compare :: PacketRefId -> PacketRefId -> Ordering
$c< :: PacketRefId -> PacketRefId -> Bool
< :: PacketRefId -> PacketRefId -> Bool
$c<= :: PacketRefId -> PacketRefId -> Bool
<= :: PacketRefId -> PacketRefId -> Bool
$c> :: PacketRefId -> PacketRefId -> Bool
> :: PacketRefId -> PacketRefId -> Bool
$c>= :: PacketRefId -> PacketRefId -> Bool
>= :: PacketRefId -> PacketRefId -> Bool
$cmax :: PacketRefId -> PacketRefId -> PacketRefId
max :: PacketRefId -> PacketRefId -> PacketRefId
$cmin :: PacketRefId -> PacketRefId -> PacketRefId
min :: PacketRefId -> PacketRefId -> PacketRefId
Ord, Int -> PacketRefId -> ShowS
[PacketRefId] -> ShowS
PacketRefId -> String
(Int -> PacketRefId -> ShowS)
-> (PacketRefId -> String)
-> ([PacketRefId] -> ShowS)
-> Show PacketRefId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PacketRefId -> ShowS
showsPrec :: Int -> PacketRefId -> ShowS
$cshow :: PacketRefId -> String
show :: PacketRefId -> String
$cshowList :: [PacketRefId] -> ShowS
showList :: [PacketRefId] -> ShowS
Show, Typeable)

data SignatureWithWireRef
    = SignatureWithWireRef
    { SignatureWithWireRef -> SignaturePayload
_signatureWithWireRefValue :: SignaturePayload
    , SignatureWithWireRef -> PacketRefId
_signatureWithWireRefRef :: PacketRefId
    }
    deriving (Typeable SignatureWithWireRef
Typeable SignatureWithWireRef =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> SignatureWithWireRef
 -> c SignatureWithWireRef)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SignatureWithWireRef)
-> (SignatureWithWireRef -> Constr)
-> (SignatureWithWireRef -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SignatureWithWireRef))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SignatureWithWireRef))
-> ((forall b. Data b => b -> b)
    -> SignatureWithWireRef -> SignatureWithWireRef)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> SignatureWithWireRef -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SignatureWithWireRef -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> SignatureWithWireRef -> m SignatureWithWireRef)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SignatureWithWireRef -> m SignatureWithWireRef)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SignatureWithWireRef -> m SignatureWithWireRef)
-> Data SignatureWithWireRef
SignatureWithWireRef -> Constr
SignatureWithWireRef -> DataType
(forall b. Data b => b -> b)
-> SignatureWithWireRef -> SignatureWithWireRef
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> SignatureWithWireRef -> u
forall u.
(forall d. Data d => d -> u) -> SignatureWithWireRef -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SignatureWithWireRef
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SignatureWithWireRef
-> c SignatureWithWireRef
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SignatureWithWireRef)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SignatureWithWireRef)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SignatureWithWireRef
-> c SignatureWithWireRef
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SignatureWithWireRef
-> c SignatureWithWireRef
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SignatureWithWireRef
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SignatureWithWireRef
$ctoConstr :: SignatureWithWireRef -> Constr
toConstr :: SignatureWithWireRef -> Constr
$cdataTypeOf :: SignatureWithWireRef -> DataType
dataTypeOf :: SignatureWithWireRef -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SignatureWithWireRef)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SignatureWithWireRef)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SignatureWithWireRef)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SignatureWithWireRef)
$cgmapT :: (forall b. Data b => b -> b)
-> SignatureWithWireRef -> SignatureWithWireRef
gmapT :: (forall b. Data b => b -> b)
-> SignatureWithWireRef -> SignatureWithWireRef
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SignatureWithWireRef -> r
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> SignatureWithWireRef -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> SignatureWithWireRef -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> SignatureWithWireRef -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> SignatureWithWireRef -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SignatureWithWireRef -> m SignatureWithWireRef
Data, SignatureWithWireRef -> SignatureWithWireRef -> Bool
(SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> (SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> Eq SignatureWithWireRef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
== :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
$c/= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
/= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
Eq, (forall x. SignatureWithWireRef -> Rep SignatureWithWireRef x)
-> (forall x. Rep SignatureWithWireRef x -> SignatureWithWireRef)
-> Generic SignatureWithWireRef
forall x. Rep SignatureWithWireRef x -> SignatureWithWireRef
forall x. SignatureWithWireRef -> Rep SignatureWithWireRef x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SignatureWithWireRef -> Rep SignatureWithWireRef x
from :: forall x. SignatureWithWireRef -> Rep SignatureWithWireRef x
$cto :: forall x. Rep SignatureWithWireRef x -> SignatureWithWireRef
to :: forall x. Rep SignatureWithWireRef x -> SignatureWithWireRef
Generic, Eq SignatureWithWireRef
Eq SignatureWithWireRef =>
(SignatureWithWireRef -> SignatureWithWireRef -> Ordering)
-> (SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> (SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> (SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> (SignatureWithWireRef -> SignatureWithWireRef -> Bool)
-> (SignatureWithWireRef
    -> SignatureWithWireRef -> SignatureWithWireRef)
-> (SignatureWithWireRef
    -> SignatureWithWireRef -> SignatureWithWireRef)
-> Ord SignatureWithWireRef
SignatureWithWireRef -> SignatureWithWireRef -> Bool
SignatureWithWireRef -> SignatureWithWireRef -> Ordering
SignatureWithWireRef
-> SignatureWithWireRef -> SignatureWithWireRef
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SignatureWithWireRef -> SignatureWithWireRef -> Ordering
compare :: SignatureWithWireRef -> SignatureWithWireRef -> Ordering
$c< :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
< :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
$c<= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
<= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
$c> :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
> :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
$c>= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
>= :: SignatureWithWireRef -> SignatureWithWireRef -> Bool
$cmax :: SignatureWithWireRef
-> SignatureWithWireRef -> SignatureWithWireRef
max :: SignatureWithWireRef
-> SignatureWithWireRef -> SignatureWithWireRef
$cmin :: SignatureWithWireRef
-> SignatureWithWireRef -> SignatureWithWireRef
min :: SignatureWithWireRef
-> SignatureWithWireRef -> SignatureWithWireRef
Ord, Int -> SignatureWithWireRef -> ShowS
[SignatureWithWireRef] -> ShowS
SignatureWithWireRef -> String
(Int -> SignatureWithWireRef -> ShowS)
-> (SignatureWithWireRef -> String)
-> ([SignatureWithWireRef] -> ShowS)
-> Show SignatureWithWireRef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SignatureWithWireRef -> ShowS
showsPrec :: Int -> SignatureWithWireRef -> ShowS
$cshow :: SignatureWithWireRef -> String
show :: SignatureWithWireRef -> String
$cshowList :: [SignatureWithWireRef] -> ShowS
showList :: [SignatureWithWireRef] -> ShowS
Show, Typeable)

data UIDWithWireRefs
    = UIDWithWireRefs
    { UIDWithWireRefs -> Text
_uidWithWireRefsValue :: Text
    , UIDWithWireRefs -> PacketRefId
_uidWithWireRefsRef :: PacketRefId
    , UIDWithWireRefs -> [SignatureWithWireRef]
_uidWithWireRefsSignatures :: [SignatureWithWireRef]
    }
    deriving (Typeable UIDWithWireRefs
Typeable UIDWithWireRefs =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> UIDWithWireRefs -> c UIDWithWireRefs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UIDWithWireRefs)
-> (UIDWithWireRefs -> Constr)
-> (UIDWithWireRefs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UIDWithWireRefs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c UIDWithWireRefs))
-> ((forall b. Data b => b -> b)
    -> UIDWithWireRefs -> UIDWithWireRefs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> UIDWithWireRefs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UIDWithWireRefs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> UIDWithWireRefs -> m UIDWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> UIDWithWireRefs -> m UIDWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> UIDWithWireRefs -> m UIDWithWireRefs)
-> Data UIDWithWireRefs
UIDWithWireRefs -> Constr
UIDWithWireRefs -> DataType
(forall b. Data b => b -> b) -> UIDWithWireRefs -> UIDWithWireRefs
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> UIDWithWireRefs -> u
forall u. (forall d. Data d => d -> u) -> UIDWithWireRefs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UIDWithWireRefs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UIDWithWireRefs -> c UIDWithWireRefs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UIDWithWireRefs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UIDWithWireRefs)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UIDWithWireRefs -> c UIDWithWireRefs
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UIDWithWireRefs -> c UIDWithWireRefs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UIDWithWireRefs
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UIDWithWireRefs
$ctoConstr :: UIDWithWireRefs -> Constr
toConstr :: UIDWithWireRefs -> Constr
$cdataTypeOf :: UIDWithWireRefs -> DataType
dataTypeOf :: UIDWithWireRefs -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UIDWithWireRefs)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UIDWithWireRefs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UIDWithWireRefs)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UIDWithWireRefs)
$cgmapT :: (forall b. Data b => b -> b) -> UIDWithWireRefs -> UIDWithWireRefs
gmapT :: (forall b. Data b => b -> b) -> UIDWithWireRefs -> UIDWithWireRefs
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UIDWithWireRefs -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UIDWithWireRefs -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> UIDWithWireRefs -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UIDWithWireRefs -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UIDWithWireRefs -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UIDWithWireRefs -> m UIDWithWireRefs
Data, UIDWithWireRefs -> UIDWithWireRefs -> Bool
(UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> (UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> Eq UIDWithWireRefs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
== :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
$c/= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
/= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
Eq, (forall x. UIDWithWireRefs -> Rep UIDWithWireRefs x)
-> (forall x. Rep UIDWithWireRefs x -> UIDWithWireRefs)
-> Generic UIDWithWireRefs
forall x. Rep UIDWithWireRefs x -> UIDWithWireRefs
forall x. UIDWithWireRefs -> Rep UIDWithWireRefs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UIDWithWireRefs -> Rep UIDWithWireRefs x
from :: forall x. UIDWithWireRefs -> Rep UIDWithWireRefs x
$cto :: forall x. Rep UIDWithWireRefs x -> UIDWithWireRefs
to :: forall x. Rep UIDWithWireRefs x -> UIDWithWireRefs
Generic, Eq UIDWithWireRefs
Eq UIDWithWireRefs =>
(UIDWithWireRefs -> UIDWithWireRefs -> Ordering)
-> (UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> (UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> (UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> (UIDWithWireRefs -> UIDWithWireRefs -> Bool)
-> (UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs)
-> (UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs)
-> Ord UIDWithWireRefs
UIDWithWireRefs -> UIDWithWireRefs -> Bool
UIDWithWireRefs -> UIDWithWireRefs -> Ordering
UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UIDWithWireRefs -> UIDWithWireRefs -> Ordering
compare :: UIDWithWireRefs -> UIDWithWireRefs -> Ordering
$c< :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
< :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
$c<= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
<= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
$c> :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
> :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
$c>= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
>= :: UIDWithWireRefs -> UIDWithWireRefs -> Bool
$cmax :: UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs
max :: UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs
$cmin :: UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs
min :: UIDWithWireRefs -> UIDWithWireRefs -> UIDWithWireRefs
Ord, Int -> UIDWithWireRefs -> ShowS
[UIDWithWireRefs] -> ShowS
UIDWithWireRefs -> String
(Int -> UIDWithWireRefs -> ShowS)
-> (UIDWithWireRefs -> String)
-> ([UIDWithWireRefs] -> ShowS)
-> Show UIDWithWireRefs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UIDWithWireRefs -> ShowS
showsPrec :: Int -> UIDWithWireRefs -> ShowS
$cshow :: UIDWithWireRefs -> String
show :: UIDWithWireRefs -> String
$cshowList :: [UIDWithWireRefs] -> ShowS
showList :: [UIDWithWireRefs] -> ShowS
Show, Typeable)

data UAtWithWireRefs
    = UAtWithWireRefs
    { UAtWithWireRefs -> [UserAttrSubPacket]
_uatWithWireRefsValue :: [UserAttrSubPacket]
    , UAtWithWireRefs -> PacketRefId
_uatWithWireRefsRef :: PacketRefId
    , UAtWithWireRefs -> [SignatureWithWireRef]
_uatWithWireRefsSignatures :: [SignatureWithWireRef]
    }
    deriving (Typeable UAtWithWireRefs
Typeable UAtWithWireRefs =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> UAtWithWireRefs -> c UAtWithWireRefs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c UAtWithWireRefs)
-> (UAtWithWireRefs -> Constr)
-> (UAtWithWireRefs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c UAtWithWireRefs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c UAtWithWireRefs))
-> ((forall b. Data b => b -> b)
    -> UAtWithWireRefs -> UAtWithWireRefs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> UAtWithWireRefs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> UAtWithWireRefs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> UAtWithWireRefs -> m UAtWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> UAtWithWireRefs -> m UAtWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> UAtWithWireRefs -> m UAtWithWireRefs)
-> Data UAtWithWireRefs
UAtWithWireRefs -> Constr
UAtWithWireRefs -> DataType
(forall b. Data b => b -> b) -> UAtWithWireRefs -> UAtWithWireRefs
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> UAtWithWireRefs -> u
forall u. (forall d. Data d => d -> u) -> UAtWithWireRefs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UAtWithWireRefs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UAtWithWireRefs -> c UAtWithWireRefs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UAtWithWireRefs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UAtWithWireRefs)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UAtWithWireRefs -> c UAtWithWireRefs
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UAtWithWireRefs -> c UAtWithWireRefs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UAtWithWireRefs
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UAtWithWireRefs
$ctoConstr :: UAtWithWireRefs -> Constr
toConstr :: UAtWithWireRefs -> Constr
$cdataTypeOf :: UAtWithWireRefs -> DataType
dataTypeOf :: UAtWithWireRefs -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UAtWithWireRefs)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UAtWithWireRefs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UAtWithWireRefs)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UAtWithWireRefs)
$cgmapT :: (forall b. Data b => b -> b) -> UAtWithWireRefs -> UAtWithWireRefs
gmapT :: (forall b. Data b => b -> b) -> UAtWithWireRefs -> UAtWithWireRefs
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UAtWithWireRefs -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UAtWithWireRefs -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> UAtWithWireRefs -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UAtWithWireRefs -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UAtWithWireRefs -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UAtWithWireRefs -> m UAtWithWireRefs
Data, UAtWithWireRefs -> UAtWithWireRefs -> Bool
(UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> (UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> Eq UAtWithWireRefs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
== :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
$c/= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
/= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
Eq, (forall x. UAtWithWireRefs -> Rep UAtWithWireRefs x)
-> (forall x. Rep UAtWithWireRefs x -> UAtWithWireRefs)
-> Generic UAtWithWireRefs
forall x. Rep UAtWithWireRefs x -> UAtWithWireRefs
forall x. UAtWithWireRefs -> Rep UAtWithWireRefs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UAtWithWireRefs -> Rep UAtWithWireRefs x
from :: forall x. UAtWithWireRefs -> Rep UAtWithWireRefs x
$cto :: forall x. Rep UAtWithWireRefs x -> UAtWithWireRefs
to :: forall x. Rep UAtWithWireRefs x -> UAtWithWireRefs
Generic, Eq UAtWithWireRefs
Eq UAtWithWireRefs =>
(UAtWithWireRefs -> UAtWithWireRefs -> Ordering)
-> (UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> (UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> (UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> (UAtWithWireRefs -> UAtWithWireRefs -> Bool)
-> (UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs)
-> (UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs)
-> Ord UAtWithWireRefs
UAtWithWireRefs -> UAtWithWireRefs -> Bool
UAtWithWireRefs -> UAtWithWireRefs -> Ordering
UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UAtWithWireRefs -> UAtWithWireRefs -> Ordering
compare :: UAtWithWireRefs -> UAtWithWireRefs -> Ordering
$c< :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
< :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
$c<= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
<= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
$c> :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
> :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
$c>= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
>= :: UAtWithWireRefs -> UAtWithWireRefs -> Bool
$cmax :: UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs
max :: UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs
$cmin :: UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs
min :: UAtWithWireRefs -> UAtWithWireRefs -> UAtWithWireRefs
Ord, Int -> UAtWithWireRefs -> ShowS
[UAtWithWireRefs] -> ShowS
UAtWithWireRefs -> String
(Int -> UAtWithWireRefs -> ShowS)
-> (UAtWithWireRefs -> String)
-> ([UAtWithWireRefs] -> ShowS)
-> Show UAtWithWireRefs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UAtWithWireRefs -> ShowS
showsPrec :: Int -> UAtWithWireRefs -> ShowS
$cshow :: UAtWithWireRefs -> String
show :: UAtWithWireRefs -> String
$cshowList :: [UAtWithWireRefs] -> ShowS
showList :: [UAtWithWireRefs] -> ShowS
Show, Typeable)

data SubkeyWithWireRefs
    = SubkeyWithWireRefs
    { SubkeyWithWireRefs -> Pkt
_subkeyWithWireRefsValue :: Pkt
    , SubkeyWithWireRefs -> PacketRefId
_subkeyWithWireRefsRef :: PacketRefId
    , SubkeyWithWireRefs -> [SignatureWithWireRef]
_subkeyWithWireRefsSignatures :: [SignatureWithWireRef]
    }
    deriving (Typeable SubkeyWithWireRefs
Typeable SubkeyWithWireRefs =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> SubkeyWithWireRefs
 -> c SubkeyWithWireRefs)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SubkeyWithWireRefs)
-> (SubkeyWithWireRefs -> Constr)
-> (SubkeyWithWireRefs -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SubkeyWithWireRefs))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SubkeyWithWireRefs))
-> ((forall b. Data b => b -> b)
    -> SubkeyWithWireRefs -> SubkeyWithWireRefs)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> SubkeyWithWireRefs -> m SubkeyWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SubkeyWithWireRefs -> m SubkeyWithWireRefs)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> SubkeyWithWireRefs -> m SubkeyWithWireRefs)
-> Data SubkeyWithWireRefs
SubkeyWithWireRefs -> Constr
SubkeyWithWireRefs -> DataType
(forall b. Data b => b -> b)
-> SubkeyWithWireRefs -> SubkeyWithWireRefs
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> u
forall u. (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SubkeyWithWireRefs
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SubkeyWithWireRefs
-> c SubkeyWithWireRefs
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SubkeyWithWireRefs)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SubkeyWithWireRefs)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SubkeyWithWireRefs
-> c SubkeyWithWireRefs
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> SubkeyWithWireRefs
-> c SubkeyWithWireRefs
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SubkeyWithWireRefs
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SubkeyWithWireRefs
$ctoConstr :: SubkeyWithWireRefs -> Constr
toConstr :: SubkeyWithWireRefs -> Constr
$cdataTypeOf :: SubkeyWithWireRefs -> DataType
dataTypeOf :: SubkeyWithWireRefs -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SubkeyWithWireRefs)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SubkeyWithWireRefs)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SubkeyWithWireRefs)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c SubkeyWithWireRefs)
$cgmapT :: (forall b. Data b => b -> b)
-> SubkeyWithWireRefs -> SubkeyWithWireRefs
gmapT :: (forall b. Data b => b -> b)
-> SubkeyWithWireRefs -> SubkeyWithWireRefs
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SubkeyWithWireRefs -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> SubkeyWithWireRefs -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> SubkeyWithWireRefs -> m SubkeyWithWireRefs
Data, SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
(SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> Eq SubkeyWithWireRefs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
== :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
$c/= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
/= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
Eq, (forall x. SubkeyWithWireRefs -> Rep SubkeyWithWireRefs x)
-> (forall x. Rep SubkeyWithWireRefs x -> SubkeyWithWireRefs)
-> Generic SubkeyWithWireRefs
forall x. Rep SubkeyWithWireRefs x -> SubkeyWithWireRefs
forall x. SubkeyWithWireRefs -> Rep SubkeyWithWireRefs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SubkeyWithWireRefs -> Rep SubkeyWithWireRefs x
from :: forall x. SubkeyWithWireRefs -> Rep SubkeyWithWireRefs x
$cto :: forall x. Rep SubkeyWithWireRefs x -> SubkeyWithWireRefs
to :: forall x. Rep SubkeyWithWireRefs x -> SubkeyWithWireRefs
Generic, Eq SubkeyWithWireRefs
Eq SubkeyWithWireRefs =>
(SubkeyWithWireRefs -> SubkeyWithWireRefs -> Ordering)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs)
-> (SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs)
-> Ord SubkeyWithWireRefs
SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
SubkeyWithWireRefs -> SubkeyWithWireRefs -> Ordering
SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Ordering
compare :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Ordering
$c< :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
< :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
$c<= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
<= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
$c> :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
> :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
$c>= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
>= :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> Bool
$cmax :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs
max :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs
$cmin :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs
min :: SubkeyWithWireRefs -> SubkeyWithWireRefs -> SubkeyWithWireRefs
Ord, Int -> SubkeyWithWireRefs -> ShowS
[SubkeyWithWireRefs] -> ShowS
SubkeyWithWireRefs -> String
(Int -> SubkeyWithWireRefs -> ShowS)
-> (SubkeyWithWireRefs -> String)
-> ([SubkeyWithWireRefs] -> ShowS)
-> Show SubkeyWithWireRefs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubkeyWithWireRefs -> ShowS
showsPrec :: Int -> SubkeyWithWireRefs -> ShowS
$cshow :: SubkeyWithWireRefs -> String
show :: SubkeyWithWireRefs -> String
$cshowList :: [SubkeyWithWireRefs] -> ShowS
showList :: [SubkeyWithWireRefs] -> ShowS
Show, Typeable)

data TKStructuredWithWireRep
    = TKStructuredWithWireRep
    { TKStructuredWithWireRep -> WireRepRefs
_tkStructuredWireRepRefs :: WireRepRefs
    , TKStructuredWithWireRep -> Maybe ByteRange
_tkStructuredWireRepRange :: Maybe ByteRange
    , TKStructuredWithWireRep -> (SomePKPayload, Maybe SKAddendum)
_tkStructuredPrimaryKey :: (SomePKPayload, Maybe SKAddendum)
    , TKStructuredWithWireRep -> PacketRefId
_tkStructuredPrimaryKeyRef :: PacketRefId
    , TKStructuredWithWireRep -> [SignatureWithWireRef]
_tkStructuredRevs :: [SignatureWithWireRef]
    , TKStructuredWithWireRep -> [SignatureWithWireRef]
_tkStructuredDirectKeySigs :: [SignatureWithWireRef]
    , TKStructuredWithWireRep -> [UIDWithWireRefs]
_tkStructuredUIDs :: [UIDWithWireRefs]
    , TKStructuredWithWireRep -> [UAtWithWireRefs]
_tkStructuredUAts :: [UAtWithWireRefs]
    , TKStructuredWithWireRep -> [SubkeyWithWireRefs]
_tkStructuredSubkeys :: [SubkeyWithWireRefs]
    , TKStructuredWithWireRep -> [PktWithWireRep]
_tkStructuredPacketRefs :: [PktWithWireRep]
    }
    deriving (Typeable TKStructuredWithWireRep
Typeable TKStructuredWithWireRep =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> TKStructuredWithWireRep
 -> c TKStructuredWithWireRep)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TKStructuredWithWireRep)
-> (TKStructuredWithWireRep -> Constr)
-> (TKStructuredWithWireRep -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TKStructuredWithWireRep))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c TKStructuredWithWireRep))
-> ((forall b. Data b => b -> b)
    -> TKStructuredWithWireRep -> TKStructuredWithWireRep)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> TKStructuredWithWireRep
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> TKStructuredWithWireRep
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> TKStructuredWithWireRep -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u) -> TKStructuredWithWireRep -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> TKStructuredWithWireRep -> m TKStructuredWithWireRep)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> TKStructuredWithWireRep -> m TKStructuredWithWireRep)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> TKStructuredWithWireRep -> m TKStructuredWithWireRep)
-> Data TKStructuredWithWireRep
TKStructuredWithWireRep -> Constr
TKStructuredWithWireRep -> DataType
(forall b. Data b => b -> b)
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> TKStructuredWithWireRep -> u
forall u.
(forall d. Data d => d -> u) -> TKStructuredWithWireRep -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKStructuredWithWireRep
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> TKStructuredWithWireRep
-> c TKStructuredWithWireRep
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKStructuredWithWireRep)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKStructuredWithWireRep)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> TKStructuredWithWireRep
-> c TKStructuredWithWireRep
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> TKStructuredWithWireRep
-> c TKStructuredWithWireRep
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKStructuredWithWireRep
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TKStructuredWithWireRep
$ctoConstr :: TKStructuredWithWireRep -> Constr
toConstr :: TKStructuredWithWireRep -> Constr
$cdataTypeOf :: TKStructuredWithWireRep -> DataType
dataTypeOf :: TKStructuredWithWireRep -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKStructuredWithWireRep)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TKStructuredWithWireRep)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKStructuredWithWireRep)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c TKStructuredWithWireRep)
$cgmapT :: (forall b. Data b => b -> b)
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
gmapT :: (forall b. Data b => b -> b)
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> TKStructuredWithWireRep
-> r
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> TKStructuredWithWireRep -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> TKStructuredWithWireRep -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> TKStructuredWithWireRep -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> TKStructuredWithWireRep -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TKStructuredWithWireRep -> m TKStructuredWithWireRep
Data, TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
(TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> (TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> Eq TKStructuredWithWireRep
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
== :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
$c/= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
/= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
Eq, (forall x.
 TKStructuredWithWireRep -> Rep TKStructuredWithWireRep x)
-> (forall x.
    Rep TKStructuredWithWireRep x -> TKStructuredWithWireRep)
-> Generic TKStructuredWithWireRep
forall x. Rep TKStructuredWithWireRep x -> TKStructuredWithWireRep
forall x. TKStructuredWithWireRep -> Rep TKStructuredWithWireRep x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TKStructuredWithWireRep -> Rep TKStructuredWithWireRep x
from :: forall x. TKStructuredWithWireRep -> Rep TKStructuredWithWireRep x
$cto :: forall x. Rep TKStructuredWithWireRep x -> TKStructuredWithWireRep
to :: forall x. Rep TKStructuredWithWireRep x -> TKStructuredWithWireRep
Generic, Eq TKStructuredWithWireRep
Eq TKStructuredWithWireRep =>
(TKStructuredWithWireRep -> TKStructuredWithWireRep -> Ordering)
-> (TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> (TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> (TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> (TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool)
-> (TKStructuredWithWireRep
    -> TKStructuredWithWireRep -> TKStructuredWithWireRep)
-> (TKStructuredWithWireRep
    -> TKStructuredWithWireRep -> TKStructuredWithWireRep)
-> Ord TKStructuredWithWireRep
TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
TKStructuredWithWireRep -> TKStructuredWithWireRep -> Ordering
TKStructuredWithWireRep
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Ordering
compare :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Ordering
$c< :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
< :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
$c<= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
<= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
$c> :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
> :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
$c>= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
>= :: TKStructuredWithWireRep -> TKStructuredWithWireRep -> Bool
$cmax :: TKStructuredWithWireRep
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
max :: TKStructuredWithWireRep
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
$cmin :: TKStructuredWithWireRep
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
min :: TKStructuredWithWireRep
-> TKStructuredWithWireRep -> TKStructuredWithWireRep
Ord, Int -> TKStructuredWithWireRep -> ShowS
[TKStructuredWithWireRep] -> ShowS
TKStructuredWithWireRep -> String
(Int -> TKStructuredWithWireRep -> ShowS)
-> (TKStructuredWithWireRep -> String)
-> ([TKStructuredWithWireRep] -> ShowS)
-> Show TKStructuredWithWireRep
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TKStructuredWithWireRep -> ShowS
showsPrec :: Int -> TKStructuredWithWireRep -> ShowS
$cshow :: TKStructuredWithWireRep -> String
show :: TKStructuredWithWireRep -> String
$cshowList :: [TKStructuredWithWireRep] -> ShowS
showList :: [TKStructuredWithWireRep] -> ShowS
Show, Typeable)

data CanonicalizeTKWithWireRepError
    = CanonicalizeStructuringError String
    | CanonicalizeMissingPacketRef PacketRefId
    deriving (Typeable CanonicalizeTKWithWireRepError
Typeable CanonicalizeTKWithWireRepError =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> CanonicalizeTKWithWireRepError
 -> c CanonicalizeTKWithWireRepError)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r)
    -> Constr
    -> c CanonicalizeTKWithWireRepError)
-> (CanonicalizeTKWithWireRepError -> Constr)
-> (CanonicalizeTKWithWireRepError -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c CanonicalizeTKWithWireRepError))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CanonicalizeTKWithWireRepError))
-> ((forall b. Data b => b -> b)
    -> CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> CanonicalizeTKWithWireRepError
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> CanonicalizeTKWithWireRepError
    -> r)
-> (forall u.
    (forall d. Data d => d -> u)
    -> CanonicalizeTKWithWireRepError -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u)
    -> CanonicalizeTKWithWireRepError
    -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> CanonicalizeTKWithWireRepError
    -> m CanonicalizeTKWithWireRepError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CanonicalizeTKWithWireRepError
    -> m CanonicalizeTKWithWireRepError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CanonicalizeTKWithWireRepError
    -> m CanonicalizeTKWithWireRepError)
-> Data CanonicalizeTKWithWireRepError
CanonicalizeTKWithWireRepError -> Constr
CanonicalizeTKWithWireRepError -> DataType
(forall b. Data b => b -> b)
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError
-> u
forall u.
(forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c CanonicalizeTKWithWireRepError
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CanonicalizeTKWithWireRepError
-> c CanonicalizeTKWithWireRepError
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c CanonicalizeTKWithWireRepError)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CanonicalizeTKWithWireRepError)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CanonicalizeTKWithWireRepError
-> c CanonicalizeTKWithWireRepError
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CanonicalizeTKWithWireRepError
-> c CanonicalizeTKWithWireRepError
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c CanonicalizeTKWithWireRepError
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c CanonicalizeTKWithWireRepError
$ctoConstr :: CanonicalizeTKWithWireRepError -> Constr
toConstr :: CanonicalizeTKWithWireRepError -> Constr
$cdataTypeOf :: CanonicalizeTKWithWireRepError -> DataType
dataTypeOf :: CanonicalizeTKWithWireRepError -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c CanonicalizeTKWithWireRepError)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c CanonicalizeTKWithWireRepError)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CanonicalizeTKWithWireRepError)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CanonicalizeTKWithWireRepError)
$cgmapT :: (forall b. Data b => b -> b)
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
gmapT :: (forall b. Data b => b -> b)
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> CanonicalizeTKWithWireRepError
-> r
$cgmapQ :: forall u.
(forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError -> [u]
$cgmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError
-> u
gmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> CanonicalizeTKWithWireRepError
-> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CanonicalizeTKWithWireRepError
-> m CanonicalizeTKWithWireRepError
Data, CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
(CanonicalizeTKWithWireRepError
 -> CanonicalizeTKWithWireRepError -> Bool)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError -> Bool)
-> Eq CanonicalizeTKWithWireRepError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
== :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
$c/= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
/= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
Eq, (forall x.
 CanonicalizeTKWithWireRepError
 -> Rep CanonicalizeTKWithWireRepError x)
-> (forall x.
    Rep CanonicalizeTKWithWireRepError x
    -> CanonicalizeTKWithWireRepError)
-> Generic CanonicalizeTKWithWireRepError
forall x.
Rep CanonicalizeTKWithWireRepError x
-> CanonicalizeTKWithWireRepError
forall x.
CanonicalizeTKWithWireRepError
-> Rep CanonicalizeTKWithWireRepError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
CanonicalizeTKWithWireRepError
-> Rep CanonicalizeTKWithWireRepError x
from :: forall x.
CanonicalizeTKWithWireRepError
-> Rep CanonicalizeTKWithWireRepError x
$cto :: forall x.
Rep CanonicalizeTKWithWireRepError x
-> CanonicalizeTKWithWireRepError
to :: forall x.
Rep CanonicalizeTKWithWireRepError x
-> CanonicalizeTKWithWireRepError
Generic, Eq CanonicalizeTKWithWireRepError
Eq CanonicalizeTKWithWireRepError =>
(CanonicalizeTKWithWireRepError
 -> CanonicalizeTKWithWireRepError -> Ordering)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError -> Bool)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError -> Bool)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError -> Bool)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError -> Bool)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError)
-> (CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError
    -> CanonicalizeTKWithWireRepError)
-> Ord CanonicalizeTKWithWireRepError
CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Ordering
CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Ordering
compare :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Ordering
$c< :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
< :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
$c<= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
<= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
$c> :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
> :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
$c>= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
>= :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> Bool
$cmax :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
max :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
$cmin :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
min :: CanonicalizeTKWithWireRepError
-> CanonicalizeTKWithWireRepError -> CanonicalizeTKWithWireRepError
Ord, Int -> CanonicalizeTKWithWireRepError -> ShowS
[CanonicalizeTKWithWireRepError] -> ShowS
CanonicalizeTKWithWireRepError -> String
(Int -> CanonicalizeTKWithWireRepError -> ShowS)
-> (CanonicalizeTKWithWireRepError -> String)
-> ([CanonicalizeTKWithWireRepError] -> ShowS)
-> Show CanonicalizeTKWithWireRepError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanonicalizeTKWithWireRepError -> ShowS
showsPrec :: Int -> CanonicalizeTKWithWireRepError -> ShowS
$cshow :: CanonicalizeTKWithWireRepError -> String
show :: CanonicalizeTKWithWireRepError -> String
$cshowList :: [CanonicalizeTKWithWireRepError] -> ShowS
showList :: [CanonicalizeTKWithWireRepError] -> ShowS
Show, Typeable)

wireRepOfTK :: TKWithWireRep -> WireRepRef
wireRepOfTK :: TKWithWireRep -> WireRepRef
wireRepOfTK = WireRepRefs -> WireRepRef
forall a. NonEmpty a -> a
NE.head (WireRepRefs -> WireRepRef)
-> (TKWithWireRep -> WireRepRefs) -> TKWithWireRep -> WireRepRef
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TKWithWireRep -> WireRepRefs
_tkWireRepRefs

wireRepsOfTK :: TKWithWireRep -> WireRepRefs
wireRepsOfTK :: TKWithWireRep -> WireRepRefs
wireRepsOfTK = TKWithWireRep -> WireRepRefs
_tkWireRepRefs

packetRefsOfTK :: TKWithWireRep -> [PktWithWireRep]
packetRefsOfTK :: TKWithWireRep -> [PktWithWireRep]
packetRefsOfTK = TKWithWireRep -> [PktWithWireRep]
_tkPackets

packetRefIdOf :: PktWithWireRep -> PacketRefId
packetRefIdOf :: PktWithWireRep -> PacketRefId
packetRefIdOf PktWithWireRep
pkt = WireRepRef -> Int -> PacketRefId
PacketRefId (PktWithWireRep -> WireRepRef
_pktWireRepRef PktWithWireRep
pkt) (PktWithWireRep -> Int
_pktIndex PktWithWireRep
pkt)

lookupPacketRef
    :: TKStructuredWithWireRep -> PacketRefId -> Maybe PktWithWireRep
lookupPacketRef :: TKStructuredWithWireRep -> PacketRefId -> Maybe PktWithWireRep
lookupPacketRef TKStructuredWithWireRep
structured PacketRefId
target =
    (PktWithWireRep -> Bool)
-> [PktWithWireRep] -> Maybe PktWithWireRep
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find
        ((PacketRefId -> PacketRefId -> Bool
forall a. Eq a => a -> a -> Bool
== PacketRefId
target) (PacketRefId -> Bool)
-> (PktWithWireRep -> PacketRefId) -> PktWithWireRep -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PktWithWireRep -> PacketRefId
packetRefIdOf)
        (TKStructuredWithWireRep -> [PktWithWireRep]
_tkStructuredPacketRefs TKStructuredWithWireRep
structured)

packetWireBytesForRef
    :: TKStructuredWithWireRep
    -> PacketRefId
    -> Either CanonicalizeTKWithWireRepError BL.ByteString
packetWireBytesForRef :: TKStructuredWithWireRep
-> PacketRefId -> Either CanonicalizeTKWithWireRepError ByteString
packetWireBytesForRef TKStructuredWithWireRep
structured PacketRefId
refId =
    case TKStructuredWithWireRep -> PacketRefId -> Maybe PktWithWireRep
lookupPacketRef TKStructuredWithWireRep
structured PacketRefId
refId of
        Just PktWithWireRep
pkt -> ByteString -> Either CanonicalizeTKWithWireRepError ByteString
forall a b. b -> Either a b
Right (PktWithWireRep
pkt PktWithWireRep
-> Getting ByteString PktWithWireRep ByteString -> ByteString
forall s a. s -> Getting a s a -> a
^. (PktWithBytes -> Const ByteString PktWithBytes)
-> PktWithWireRep -> Const ByteString PktWithWireRep
Lens' PktWithWireRep PktWithBytes
pktWireRep ((PktWithBytes -> Const ByteString PktWithBytes)
 -> PktWithWireRep -> Const ByteString PktWithWireRep)
-> ((ByteString -> Const ByteString ByteString)
    -> PktWithBytes -> Const ByteString PktWithBytes)
-> Getting ByteString PktWithWireRep ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> Const ByteString ByteString)
-> PktWithBytes -> Const ByteString PktWithBytes
Lens' PktWithBytes ByteString
pktRaw)
        Maybe PktWithWireRep
Nothing -> CanonicalizeTKWithWireRepError
-> Either CanonicalizeTKWithWireRepError ByteString
forall a b. a -> Either a b
Left (PacketRefId -> CanonicalizeTKWithWireRepError
CanonicalizeMissingPacketRef PacketRefId
refId)

signatureWireSortKey
    :: TKStructuredWithWireRep
    -> SignatureWithWireRef
    -> Either
        CanonicalizeTKWithWireRepError
        (BL.ByteString, PacketRefId)
signatureWireSortKey :: TKStructuredWithWireRep
-> SignatureWithWireRef
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
signatureWireSortKey TKStructuredWithWireRep
structured SignatureWithWireRef
sig =
    (\ByteString
raw -> (ByteString
raw, SignatureWithWireRef -> PacketRefId
_signatureWithWireRefRef SignatureWithWireRef
sig))
        (ByteString -> (ByteString, PacketRefId))
-> Either CanonicalizeTKWithWireRepError ByteString
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> PacketRefId -> Either CanonicalizeTKWithWireRepError ByteString
packetWireBytesForRef TKStructuredWithWireRep
structured (SignatureWithWireRef -> PacketRefId
_signatureWithWireRefRef SignatureWithWireRef
sig)

uidWireSortKey
    :: TKStructuredWithWireRep
    -> UIDWithWireRefs
    -> Either
        CanonicalizeTKWithWireRepError
        (BL.ByteString, PacketRefId)
uidWireSortKey :: TKStructuredWithWireRep
-> UIDWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uidWireSortKey TKStructuredWithWireRep
structured UIDWithWireRefs
uid =
    (\ByteString
raw -> (ByteString
raw, UIDWithWireRefs -> PacketRefId
_uidWithWireRefsRef UIDWithWireRefs
uid))
        (ByteString -> (ByteString, PacketRefId))
-> Either CanonicalizeTKWithWireRepError ByteString
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> PacketRefId -> Either CanonicalizeTKWithWireRepError ByteString
packetWireBytesForRef TKStructuredWithWireRep
structured (UIDWithWireRefs -> PacketRefId
_uidWithWireRefsRef UIDWithWireRefs
uid)

uatWireSortKey
    :: TKStructuredWithWireRep
    -> UAtWithWireRefs
    -> Either
        CanonicalizeTKWithWireRepError
        (BL.ByteString, PacketRefId)
uatWireSortKey :: TKStructuredWithWireRep
-> UAtWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uatWireSortKey TKStructuredWithWireRep
structured UAtWithWireRefs
uat =
    (\ByteString
raw -> (ByteString
raw, UAtWithWireRefs -> PacketRefId
_uatWithWireRefsRef UAtWithWireRefs
uat))
        (ByteString -> (ByteString, PacketRefId))
-> Either CanonicalizeTKWithWireRepError ByteString
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> PacketRefId -> Either CanonicalizeTKWithWireRepError ByteString
packetWireBytesForRef TKStructuredWithWireRep
structured (UAtWithWireRefs -> PacketRefId
_uatWithWireRefsRef UAtWithWireRefs
uat)

subkeyWireSortKey
    :: TKStructuredWithWireRep
    -> SubkeyWithWireRefs
    -> Either
        CanonicalizeTKWithWireRepError
        (BL.ByteString, PacketRefId)
subkeyWireSortKey :: TKStructuredWithWireRep
-> SubkeyWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
subkeyWireSortKey TKStructuredWithWireRep
structured SubkeyWithWireRefs
sub =
    (\ByteString
raw -> (ByteString
raw, SubkeyWithWireRefs -> PacketRefId
_subkeyWithWireRefsRef SubkeyWithWireRefs
sub))
        (ByteString -> (ByteString, PacketRefId))
-> Either CanonicalizeTKWithWireRepError ByteString
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> PacketRefId -> Either CanonicalizeTKWithWireRepError ByteString
packetWireBytesForRef TKStructuredWithWireRep
structured (SubkeyWithWireRefs -> PacketRefId
_subkeyWithWireRefsRef SubkeyWithWireRefs
sub)

compareSignatureWithWireRefCanonical
    :: TKStructuredWithWireRep
    -> SignatureWithWireRef
    -> SignatureWithWireRef
    -> Either CanonicalizeTKWithWireRepError Ordering
compareSignatureWithWireRefCanonical :: TKStructuredWithWireRep
-> SignatureWithWireRef
-> SignatureWithWireRef
-> Either CanonicalizeTKWithWireRepError Ordering
compareSignatureWithWireRefCanonical TKStructuredWithWireRep
structured SignatureWithWireRef
a SignatureWithWireRef
b =
    (ByteString, PacketRefId) -> (ByteString, PacketRefId) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
        ((ByteString, PacketRefId)
 -> (ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either
     CanonicalizeTKWithWireRepError
     ((ByteString, PacketRefId) -> Ordering)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> SignatureWithWireRef
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
signatureWireSortKey TKStructuredWithWireRep
structured SignatureWithWireRef
a
        Either
  CanonicalizeTKWithWireRepError
  ((ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either CanonicalizeTKWithWireRepError Ordering
forall a b.
Either CanonicalizeTKWithWireRepError (a -> b)
-> Either CanonicalizeTKWithWireRepError a
-> Either CanonicalizeTKWithWireRepError b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TKStructuredWithWireRep
-> SignatureWithWireRef
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
signatureWireSortKey TKStructuredWithWireRep
structured SignatureWithWireRef
b

compareUIDWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> UIDWithWireRefs
    -> UIDWithWireRefs
    -> Either CanonicalizeTKWithWireRepError Ordering
compareUIDWithWireRefsCanonical :: TKStructuredWithWireRep
-> UIDWithWireRefs
-> UIDWithWireRefs
-> Either CanonicalizeTKWithWireRepError Ordering
compareUIDWithWireRefsCanonical TKStructuredWithWireRep
structured UIDWithWireRefs
a UIDWithWireRefs
b =
    (ByteString, PacketRefId) -> (ByteString, PacketRefId) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
        ((ByteString, PacketRefId)
 -> (ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either
     CanonicalizeTKWithWireRepError
     ((ByteString, PacketRefId) -> Ordering)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> UIDWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uidWireSortKey TKStructuredWithWireRep
structured UIDWithWireRefs
a
        Either
  CanonicalizeTKWithWireRepError
  ((ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either CanonicalizeTKWithWireRepError Ordering
forall a b.
Either CanonicalizeTKWithWireRepError (a -> b)
-> Either CanonicalizeTKWithWireRepError a
-> Either CanonicalizeTKWithWireRepError b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TKStructuredWithWireRep
-> UIDWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uidWireSortKey TKStructuredWithWireRep
structured UIDWithWireRefs
b

compareUAtWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> UAtWithWireRefs
    -> UAtWithWireRefs
    -> Either CanonicalizeTKWithWireRepError Ordering
compareUAtWithWireRefsCanonical :: TKStructuredWithWireRep
-> UAtWithWireRefs
-> UAtWithWireRefs
-> Either CanonicalizeTKWithWireRepError Ordering
compareUAtWithWireRefsCanonical TKStructuredWithWireRep
structured UAtWithWireRefs
a UAtWithWireRefs
b =
    (ByteString, PacketRefId) -> (ByteString, PacketRefId) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
        ((ByteString, PacketRefId)
 -> (ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either
     CanonicalizeTKWithWireRepError
     ((ByteString, PacketRefId) -> Ordering)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> UAtWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uatWireSortKey TKStructuredWithWireRep
structured UAtWithWireRefs
a
        Either
  CanonicalizeTKWithWireRepError
  ((ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either CanonicalizeTKWithWireRepError Ordering
forall a b.
Either CanonicalizeTKWithWireRepError (a -> b)
-> Either CanonicalizeTKWithWireRepError a
-> Either CanonicalizeTKWithWireRepError b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TKStructuredWithWireRep
-> UAtWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
uatWireSortKey TKStructuredWithWireRep
structured UAtWithWireRefs
b

compareSubkeyWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> SubkeyWithWireRefs
    -> SubkeyWithWireRefs
    -> Either CanonicalizeTKWithWireRepError Ordering
compareSubkeyWithWireRefsCanonical :: TKStructuredWithWireRep
-> SubkeyWithWireRefs
-> SubkeyWithWireRefs
-> Either CanonicalizeTKWithWireRepError Ordering
compareSubkeyWithWireRefsCanonical TKStructuredWithWireRep
structured SubkeyWithWireRefs
a SubkeyWithWireRefs
b =
    (ByteString, PacketRefId) -> (ByteString, PacketRefId) -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
        ((ByteString, PacketRefId)
 -> (ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either
     CanonicalizeTKWithWireRepError
     ((ByteString, PacketRefId) -> Ordering)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> SubkeyWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
subkeyWireSortKey TKStructuredWithWireRep
structured SubkeyWithWireRefs
a
        Either
  CanonicalizeTKWithWireRepError
  ((ByteString, PacketRefId) -> Ordering)
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
-> Either CanonicalizeTKWithWireRepError Ordering
forall a b.
Either CanonicalizeTKWithWireRepError (a -> b)
-> Either CanonicalizeTKWithWireRepError a
-> Either CanonicalizeTKWithWireRepError b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TKStructuredWithWireRep
-> SubkeyWithWireRefs
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
subkeyWireSortKey TKStructuredWithWireRep
structured SubkeyWithWireRefs
b

sortCanonicalByKey
    :: Ord key
    => (a -> Either CanonicalizeTKWithWireRepError key)
    -> [a]
    -> Either CanonicalizeTKWithWireRepError [a]
sortCanonicalByKey :: forall key a.
Ord key =>
(a -> Either CanonicalizeTKWithWireRepError key)
-> [a] -> Either CanonicalizeTKWithWireRepError [a]
sortCanonicalByKey a -> Either CanonicalizeTKWithWireRepError key
keyFn [a]
xs =
    ((key, a) -> a) -> [(key, a)] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map (key, a) -> a
forall a b. (a, b) -> b
snd ([(key, a)] -> [a])
-> ([(key, a)] -> [(key, a)]) -> [(key, a)] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((key, a) -> key) -> [(key, a)] -> [(key, a)]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn (key, a) -> key
forall a b. (a, b) -> a
fst
        ([(key, a)] -> [a])
-> Either CanonicalizeTKWithWireRepError [(key, a)]
-> Either CanonicalizeTKWithWireRepError [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a -> Either CanonicalizeTKWithWireRepError (key, a))
-> [a] -> Either CanonicalizeTKWithWireRepError [(key, a)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (\a
x -> (\key
k -> (key
k, a
x)) (key -> (key, a))
-> Either CanonicalizeTKWithWireRepError key
-> Either CanonicalizeTKWithWireRepError (key, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> Either CanonicalizeTKWithWireRepError key
keyFn a
x) [a]
xs

sortSignatureWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> [SignatureWithWireRef]
    -> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical :: TKStructuredWithWireRep
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical TKStructuredWithWireRep
structured =
    (SignatureWithWireRef
 -> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId))
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
forall key a.
Ord key =>
(a -> Either CanonicalizeTKWithWireRepError key)
-> [a] -> Either CanonicalizeTKWithWireRepError [a]
sortCanonicalByKey (TKStructuredWithWireRep
-> SignatureWithWireRef
-> Either CanonicalizeTKWithWireRepError (ByteString, PacketRefId)
signatureWireSortKey TKStructuredWithWireRep
structured)

sortUIDWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> [UIDWithWireRefs]
    -> Either CanonicalizeTKWithWireRepError [UIDWithWireRefs]
sortUIDWithWireRefsCanonical :: TKStructuredWithWireRep
-> [UIDWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [UIDWithWireRefs]
sortUIDWithWireRefsCanonical TKStructuredWithWireRep
structured [UIDWithWireRefs]
uids = do
    normalized <-
        (UIDWithWireRefs
 -> Either CanonicalizeTKWithWireRepError UIDWithWireRefs)
-> [UIDWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [UIDWithWireRefs]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse
            ( \UIDWithWireRefs
uid ->
                (\[SignatureWithWireRef]
sigs -> UIDWithWireRefs
uid {_uidWithWireRefsSignatures = sigs})
                    ([SignatureWithWireRef] -> UIDWithWireRefs)
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError UIDWithWireRefs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical
                        TKStructuredWithWireRep
structured
                        (UIDWithWireRefs -> [SignatureWithWireRef]
_uidWithWireRefsSignatures UIDWithWireRefs
uid)
            )
            [UIDWithWireRefs]
uids
    sortCanonicalByKey (uidWireSortKey structured) normalized

sortUAtWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> [UAtWithWireRefs]
    -> Either CanonicalizeTKWithWireRepError [UAtWithWireRefs]
sortUAtWithWireRefsCanonical :: TKStructuredWithWireRep
-> [UAtWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [UAtWithWireRefs]
sortUAtWithWireRefsCanonical TKStructuredWithWireRep
structured [UAtWithWireRefs]
uats = do
    normalized <-
        (UAtWithWireRefs
 -> Either CanonicalizeTKWithWireRepError UAtWithWireRefs)
-> [UAtWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [UAtWithWireRefs]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse
            ( \UAtWithWireRefs
uat ->
                (\[SignatureWithWireRef]
sigs -> UAtWithWireRefs
uat {_uatWithWireRefsSignatures = sigs})
                    ([SignatureWithWireRef] -> UAtWithWireRefs)
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError UAtWithWireRefs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical
                        TKStructuredWithWireRep
structured
                        (UAtWithWireRefs -> [SignatureWithWireRef]
_uatWithWireRefsSignatures UAtWithWireRefs
uat)
            )
            [UAtWithWireRefs]
uats
    sortCanonicalByKey (uatWireSortKey structured) normalized

sortSubkeyWithWireRefsCanonical
    :: TKStructuredWithWireRep
    -> [SubkeyWithWireRefs]
    -> Either CanonicalizeTKWithWireRepError [SubkeyWithWireRefs]
sortSubkeyWithWireRefsCanonical :: TKStructuredWithWireRep
-> [SubkeyWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [SubkeyWithWireRefs]
sortSubkeyWithWireRefsCanonical TKStructuredWithWireRep
structured [SubkeyWithWireRefs]
subs = do
    normalized <-
        (SubkeyWithWireRefs
 -> Either CanonicalizeTKWithWireRepError SubkeyWithWireRefs)
-> [SubkeyWithWireRefs]
-> Either CanonicalizeTKWithWireRepError [SubkeyWithWireRefs]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse
            ( \SubkeyWithWireRefs
sub ->
                (\[SignatureWithWireRef]
sigs -> SubkeyWithWireRefs
sub {_subkeyWithWireRefsSignatures = sigs})
                    ([SignatureWithWireRef] -> SubkeyWithWireRefs)
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError SubkeyWithWireRefs
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TKStructuredWithWireRep
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical
                        TKStructuredWithWireRep
structured
                        (SubkeyWithWireRefs -> [SignatureWithWireRef]
_subkeyWithWireRefsSignatures SubkeyWithWireRefs
sub)
            )
            [SubkeyWithWireRefs]
subs
    sortCanonicalByKey (subkeyWireSortKey structured) normalized

canonicalizeTKStructuredWithWireRep
    :: TKStructuredWithWireRep
    -> Either CanonicalizeTKWithWireRepError (TK 'MixedTK)
canonicalizeTKStructuredWithWireRep :: TKStructuredWithWireRep
-> Either CanonicalizeTKWithWireRepError (TK 'MixedTK)
canonicalizeTKStructuredWithWireRep TKStructuredWithWireRep
structured = do
    revs <-
        TKStructuredWithWireRep
-> [SignatureWithWireRef]
-> Either CanonicalizeTKWithWireRepError [SignatureWithWireRef]
sortSignatureWithWireRefsCanonical
            TKStructuredWithWireRep
structured
            (TKStructuredWithWireRep -> [SignatureWithWireRef]
_tkStructuredRevs TKStructuredWithWireRep
structured)
    directKeySigs <-
        sortSignatureWithWireRefsCanonical
            structured
            (_tkStructuredDirectKeySigs structured)
    uids <-
        sortUIDWithWireRefsCanonical
            structured
            (_tkStructuredUIDs structured)
    uats <-
        sortUAtWithWireRefsCanonical
            structured
            (_tkStructuredUAts structured)
    subs <-
        sortSubkeyWithWireRefsCanonical
            structured
            (_tkStructuredSubkeys structured)
    let (pkp, mska) = _tkStructuredPrimaryKey structured
        convertSub SubkeyWithWireRefs
sub =
            (,)
                (SomeKeyPkt
 -> [SignaturePayload] -> (SomeKeyPkt, [SignaturePayload]))
-> Either CanonicalizeTKWithWireRepError SomeKeyPkt
-> Either
     CanonicalizeTKWithWireRepError
     ([SignaturePayload] -> (SomeKeyPkt, [SignaturePayload]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CanonicalizeTKWithWireRepError
-> Maybe SomeKeyPkt
-> Either CanonicalizeTKWithWireRepError SomeKeyPkt
forall a b. a -> Maybe b -> Either a b
note
                    ( String -> CanonicalizeTKWithWireRepError
CanonicalizeStructuringError
                        ( String
"expected key packet in structured subkey, got "
                            String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show (Pkt -> Word8
pktTag (SubkeyWithWireRefs -> Pkt
_subkeyWithWireRefsValue SubkeyWithWireRefs
sub))
                        )
                    )
                    (Pkt -> Maybe SomeKeyPkt
pktToSomeKeyPkt (SubkeyWithWireRefs -> Pkt
_subkeyWithWireRefsValue SubkeyWithWireRefs
sub))
                Either
  CanonicalizeTKWithWireRepError
  ([SignaturePayload] -> (SomeKeyPkt, [SignaturePayload]))
-> Either CanonicalizeTKWithWireRepError [SignaturePayload]
-> Either
     CanonicalizeTKWithWireRepError (SomeKeyPkt, [SignaturePayload])
forall a b.
Either CanonicalizeTKWithWireRepError (a -> b)
-> Either CanonicalizeTKWithWireRepError a
-> Either CanonicalizeTKWithWireRepError b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [SignaturePayload]
-> Either CanonicalizeTKWithWireRepError [SignaturePayload]
forall a. a -> Either CanonicalizeTKWithWireRepError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
                    ( (SignatureWithWireRef -> SignaturePayload)
-> [SignatureWithWireRef] -> [SignaturePayload]
forall a b. (a -> b) -> [a] -> [b]
map
                        SignatureWithWireRef -> SignaturePayload
_signatureWithWireRefValue
                        (SubkeyWithWireRefs -> [SignatureWithWireRef]
_subkeyWithWireRefsSignatures SubkeyWithWireRefs
sub)
                    )
    mixedSubs <- traverse convertSub subs
    return
        TK
            { _tkPrimaryKey = mkPrimaryKeyPkt pkp mska
            , _tkRevs = map _signatureWithWireRefValue revs
            , _tkDirectKeySigs = map _signatureWithWireRefValue directKeySigs
            , _tkUIDs =
                map
                    ( _uidWithWireRefsValue
                        &&& (map _signatureWithWireRefValue . _uidWithWireRefsSignatures)
                    )
                    uids
            , _tkUAts =
                map
                    ( _uatWithWireRefsValue
                        &&& (map _signatureWithWireRefValue . _uatWithWireRefsSignatures)
                    )
                    uats
            , _tkSubs = mixedSubs
            }

canonicalizeTKWithWireRep
    :: TKWithWireRep
    -> Either CanonicalizeTKWithWireRepError (TK 'MixedTK)
canonicalizeTKWithWireRep :: TKWithWireRep
-> Either CanonicalizeTKWithWireRepError (TK 'MixedTK)
canonicalizeTKWithWireRep TKWithWireRep
tk = do
    structured <-
        case TKWithWireRep -> Either String TKStructuredWithWireRep
toStructuredTKWithWireRep TKWithWireRep
tk of
            Left String
err -> CanonicalizeTKWithWireRepError
-> Either CanonicalizeTKWithWireRepError TKStructuredWithWireRep
forall a b. a -> Either a b
Left (String -> CanonicalizeTKWithWireRepError
CanonicalizeStructuringError String
err)
            Right TKStructuredWithWireRep
s -> TKStructuredWithWireRep
-> Either CanonicalizeTKWithWireRepError TKStructuredWithWireRep
forall a b. b -> Either a b
Right TKStructuredWithWireRep
s
    canonicalizeTKStructuredWithWireRep structured

toStructuredTKWithWireRep
    :: TKWithWireRep -> Either String TKStructuredWithWireRep
toStructuredTKWithWireRep :: TKWithWireRep -> Either String TKStructuredWithWireRep
toStructuredTKWithWireRep TKWithWireRep
tkWithRefs = do
    let tk :: TK 'MixedTK
tk = TKWithWireRep -> TK 'MixedTK
_tkValue TKWithWireRep
tkWithRefs
        refs :: [PktWithWireRep]
refs = TKWithWireRep -> [PktWithWireRep]
_tkPackets TKWithWireRep
tkWithRefs
        (SomePKPayload
pkp, Maybe SKAddendum
mska) =
            ( SomeKeyPkt -> SomePKPayload
someKeyPktPKPayload (TK 'MixedTK -> TKKeyPkt 'MixedTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'MixedTK
tk)
            , SomeKeyPkt -> Maybe SKAddendum
someKeyPktMaybeSKAddendum (TK 'MixedTK -> TKKeyPkt 'MixedTK
forall (k :: TKKind). TK k -> TKKeyPkt k
_tkPrimaryKey TK 'MixedTK
tk)
            )
        primaryPkt :: Pkt
primaryPkt = SomeKeyPkt -> Pkt
someKeyPktToPkt (SomePKPayload -> Maybe SKAddendum -> SomeKeyPkt
mkPrimaryKeyPkt SomePKPayload
pkp Maybe SKAddendum
mska)
    zipper <-
        String
-> Maybe (PacketZipper PktWithWireRep)
-> Either String (PacketZipper PktWithWireRep)
forall a b. a -> Maybe b -> Either a b
note
            String
"no packet references available for TK 'MixedTK structuring"
            ([PktWithWireRep] -> Maybe (PacketZipper PktWithWireRep)
forall a. [a] -> Maybe (PacketZipper a)
zFromList [PktWithWireRep]
refs)
    (primaryRef, z1') <-
        consumePktZ "primary key packet" primaryPkt zipper
    -- Move past the primary key to process its signatures and following packets
    z1 <- case zMoveNext z1' of
        Just PacketZipper PktWithWireRep
z -> PacketZipper PktWithWireRep
-> Either String (PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right PacketZipper PktWithWireRep
z
        Maybe (PacketZipper PktWithWireRep)
Nothing ->
            -- Primary key is the only packet; only valid if no revisions, UIDs, UAts, or subkeys
            if [SignaturePayload] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (TK 'MixedTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkRevs TK 'MixedTK
tk)
                Bool -> Bool -> Bool
&& [SignaturePayload] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (TK 'MixedTK -> [SignaturePayload]
forall (k :: TKKind). TK k -> [SignaturePayload]
_tkDirectKeySigs TK 'MixedTK
tk)
                Bool -> Bool -> Bool
&& [(Text, [SignaturePayload])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (TK 'MixedTK -> [(Text, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(Text, [SignaturePayload])]
_tkUIDs TK 'MixedTK
tk)
                Bool -> Bool -> Bool
&& [([UserAttrSubPacket], [SignaturePayload])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (TK 'MixedTK -> [([UserAttrSubPacket], [SignaturePayload])]
forall (k :: TKKind).
TK k -> [([UserAttrSubPacket], [SignaturePayload])]
_tkUAts TK 'MixedTK
tk)
                Bool -> Bool -> Bool
&& [(SomeKeyPkt, [SignaturePayload])] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (TK 'MixedTK -> [(TKKeyPkt 'MixedTK, [SignaturePayload])]
forall (k :: TKKind). TK k -> [(TKKeyPkt k, [SignaturePayload])]
_tkSubs TK 'MixedTK
tk)
                then PacketZipper PktWithWireRep
-> Either String (PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right PacketZipper PktWithWireRep
z1'
                else
                    String -> Either String (PacketZipper PktWithWireRep)
forall a b. a -> Either a b
Left String
"missing signatures/UIDs/subkeys after primary key packet"
    (revs, z2) <-
        consumeSigsZ "key-revocation signatures" (_tkRevs tk) z1
    (directKeySigs, z3) <-
        consumeSigsZ "direct-key signatures" (_tkDirectKeySigs tk) z2
    (uids, z4) <- consumeUIDsZ (_tkUIDs tk) z3
    (uats, z5) <- consumeUAtsZ (_tkUAts tk) z4
    (subs, z6) <-
        consumeSubsZ
            (map (\(SomeKeyPkt
kp, [SignaturePayload]
sigs) -> (SomeKeyPkt -> Pkt
someKeyPktToPkt SomeKeyPkt
kp, [SignaturePayload]
sigs)) (_tkSubs tk))
            z5
    -- Check if there are trailing packets AFTER the current focus (not including it)
    case _zpAfter z6 of
        [] ->
            TKStructuredWithWireRep -> Either String TKStructuredWithWireRep
forall a b. b -> Either a b
Right
                ( WireRepRefs
-> Maybe ByteRange
-> (SomePKPayload, Maybe SKAddendum)
-> PacketRefId
-> [SignatureWithWireRef]
-> [SignatureWithWireRef]
-> [UIDWithWireRefs]
-> [UAtWithWireRefs]
-> [SubkeyWithWireRefs]
-> [PktWithWireRep]
-> TKStructuredWithWireRep
TKStructuredWithWireRep
                    (TKWithWireRep -> WireRepRefs
_tkWireRepRefs TKWithWireRep
tkWithRefs)
                    (TKWithWireRep -> Maybe ByteRange
_tkWireRepRange TKWithWireRep
tkWithRefs)
                    (SomePKPayload
pkp, Maybe SKAddendum
mska)
                    (PktWithWireRep -> PacketRefId
packetRefIdOf PktWithWireRep
primaryRef)
                    [SignatureWithWireRef]
revs
                    [SignatureWithWireRef]
directKeySigs
                    [UIDWithWireRefs]
uids
                    [UAtWithWireRefs]
uats
                    [SubkeyWithWireRefs]
subs
                    (TKWithWireRep -> [PktWithWireRep]
_tkPackets TKWithWireRep
tkWithRefs)
                )
        (PktWithWireRep
unexpected : [PktWithWireRep]
_) ->
            String -> Either String TKStructuredWithWireRep
forall a b. a -> Either a b
Left
                ( String
"unexpected trailing packet reference at position "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (PacketZipper PktWithWireRep -> Int
forall a. PacketZipper a -> Int
zPosition PacketZipper PktWithWireRep
z5 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" while structuring TK 'MixedTK provenance (tag "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show (Pkt -> Word8
pktTag (PktWithWireRep
unexpected PktWithWireRep -> Getting Pkt PktWithWireRep Pkt -> Pkt
forall s a. s -> Getting a s a -> a
^. (PktWithBytes -> Const Pkt PktWithBytes)
-> PktWithWireRep -> Const Pkt PktWithWireRep
Lens' PktWithWireRep PktWithBytes
pktWireRep ((PktWithBytes -> Const Pkt PktWithBytes)
 -> PktWithWireRep -> Const Pkt PktWithWireRep)
-> ((Pkt -> Const Pkt Pkt)
    -> PktWithBytes -> Const Pkt PktWithBytes)
-> Getting Pkt PktWithWireRep Pkt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pkt -> Const Pkt Pkt) -> PktWithBytes -> Const Pkt PktWithBytes
Lens' PktWithBytes Pkt
pktValue))
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
                )
  where
    consumePktZ
        :: String
        -> Pkt
        -> PacketZipper PktWithWireRep
        -> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
    consumePktZ :: String
-> Pkt
-> PacketZipper PktWithWireRep
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
consumePktZ String
context Pkt
expected PacketZipper PktWithWireRep
z
        | (PacketZipper PktWithWireRep -> PktWithWireRep
forall a. PacketZipper a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract PacketZipper PktWithWireRep
z) PktWithWireRep -> Getting Pkt PktWithWireRep Pkt -> Pkt
forall s a. s -> Getting a s a -> a
^. (PktWithBytes -> Const Pkt PktWithBytes)
-> PktWithWireRep -> Const Pkt PktWithWireRep
Lens' PktWithWireRep PktWithBytes
pktWireRep ((PktWithBytes -> Const Pkt PktWithBytes)
 -> PktWithWireRep -> Const Pkt PktWithWireRep)
-> ((Pkt -> Const Pkt Pkt)
    -> PktWithBytes -> Const Pkt PktWithBytes)
-> Getting Pkt PktWithWireRep Pkt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pkt -> Const Pkt Pkt) -> PktWithBytes -> Const Pkt PktWithBytes
Lens' PktWithBytes Pkt
pktValue Pkt -> Pkt -> Bool
forall a. Eq a => a -> a -> Bool
== Pkt
expected =
            (PktWithWireRep, PacketZipper PktWithWireRep)
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right (PacketZipper PktWithWireRep -> PktWithWireRep
forall a. PacketZipper a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract PacketZipper PktWithWireRep
z, PacketZipper PktWithWireRep
z)
        | Bool
otherwise =
            String
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
forall a b. a -> Either a b
Left
                ( String
"packet/reference mismatch for "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
context
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" at position "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (PacketZipper PktWithWireRep -> Int
forall a. PacketZipper a -> Int
zPosition PacketZipper PktWithWireRep
z)
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": expected tag "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show (Pkt -> Word8
pktTag Pkt
expected)
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", got tag "
                    String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word8 -> String
forall a. Show a => a -> String
show (Pkt -> Word8
pktTag ((PacketZipper PktWithWireRep -> PktWithWireRep
forall a. PacketZipper a -> a
forall (w :: * -> *) a. Comonad w => w a -> a
extract PacketZipper PktWithWireRep
z) PktWithWireRep -> Getting Pkt PktWithWireRep Pkt -> Pkt
forall s a. s -> Getting a s a -> a
^. (PktWithBytes -> Const Pkt PktWithBytes)
-> PktWithWireRep -> Const Pkt PktWithWireRep
Lens' PktWithWireRep PktWithBytes
pktWireRep ((PktWithBytes -> Const Pkt PktWithBytes)
 -> PktWithWireRep -> Const Pkt PktWithWireRep)
-> ((Pkt -> Const Pkt Pkt)
    -> PktWithBytes -> Const Pkt PktWithBytes)
-> Getting Pkt PktWithWireRep Pkt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pkt -> Const Pkt Pkt) -> PktWithBytes -> Const Pkt PktWithBytes
Lens' PktWithBytes Pkt
pktValue))
                )

    tryMoveNext
        :: String
        -> PacketZipper PktWithWireRep
        -> Bool
        -> Either String (PacketZipper PktWithWireRep)
    tryMoveNext :: String
-> PacketZipper PktWithWireRep
-> Bool
-> Either String (PacketZipper PktWithWireRep)
tryMoveNext String
errorPrefix PacketZipper PktWithWireRep
z Bool
isLastItem =
        case PacketZipper PktWithWireRep -> Maybe (PacketZipper PktWithWireRep)
forall a. PacketZipper a -> Maybe (PacketZipper a)
zMoveNext PacketZipper PktWithWireRep
z of
            Just PacketZipper PktWithWireRep
z' -> PacketZipper PktWithWireRep
-> Either String (PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right PacketZipper PktWithWireRep
z'
            Maybe (PacketZipper PktWithWireRep)
Nothing ->
                if Bool
isLastItem
                    then PacketZipper PktWithWireRep
-> Either String (PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right PacketZipper PktWithWireRep
z
                    else
                        String -> Either String (PacketZipper PktWithWireRep)
forall a b. a -> Either a b
Left
                            ( String
errorPrefix
                                String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" at position "
                                String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (PacketZipper PktWithWireRep -> Int
forall a. PacketZipper a -> Int
zPosition PacketZipper PktWithWireRep
z)
                            )

    consumeSigsZ
        :: String
        -> [SignaturePayload]
        -> PacketZipper PktWithWireRep
        -> Either
            String
            ([SignatureWithWireRef], PacketZipper PktWithWireRep)
    consumeSigsZ :: String
-> [SignaturePayload]
-> PacketZipper PktWithWireRep
-> Either
     String ([SignatureWithWireRef], PacketZipper PktWithWireRep)
consumeSigsZ String
context [SignaturePayload]
sigs PacketZipper PktWithWireRep
z = [SignatureWithWireRef]
-> [SignaturePayload]
-> PacketZipper PktWithWireRep
-> Either
     String ([SignatureWithWireRef], PacketZipper PktWithWireRep)
go [] [SignaturePayload]
sigs PacketZipper PktWithWireRep
z
      where
        go :: [SignatureWithWireRef]
-> [SignaturePayload]
-> PacketZipper PktWithWireRep
-> Either
     String ([SignatureWithWireRef], PacketZipper PktWithWireRep)
go [SignatureWithWireRef]
acc [] PacketZipper PktWithWireRep
zipper = ([SignatureWithWireRef], PacketZipper PktWithWireRep)
-> Either
     String ([SignatureWithWireRef], PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right ([SignatureWithWireRef] -> [SignatureWithWireRef]
forall a. [a] -> [a]
reverse [SignatureWithWireRef]
acc, PacketZipper PktWithWireRep
zipper)
        go [SignatureWithWireRef]
acc (SignaturePayload
sig : [SignaturePayload]
sigRest) PacketZipper PktWithWireRep
zipper = do
            (sigPkt, z') <- String
-> Pkt
-> PacketZipper PktWithWireRep
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
consumePktZ String
context (SignaturePayload -> Pkt
SignaturePkt SignaturePayload
sig) PacketZipper PktWithWireRep
zipper
            z'' <- tryMoveNext "missing signature packet" z' (null sigRest)
            go
                (SignatureWithWireRef sig (packetRefIdOf sigPkt) : acc)
                sigRest
                z''

    consumeUIDsZ
        :: [(Text, [SignaturePayload])]
        -> PacketZipper PktWithWireRep
        -> Either String ([UIDWithWireRefs], PacketZipper PktWithWireRep)
    consumeUIDsZ :: [(Text, [SignaturePayload])]
-> PacketZipper PktWithWireRep
-> Either String ([UIDWithWireRefs], PacketZipper PktWithWireRep)
consumeUIDsZ [] PacketZipper PktWithWireRep
z = ([UIDWithWireRefs], PacketZipper PktWithWireRep)
-> Either String ([UIDWithWireRefs], PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right ([], PacketZipper PktWithWireRep
z)
    consumeUIDsZ ((Text
uid, [SignaturePayload]
sigs) : [(Text, [SignaturePayload])]
rest) PacketZipper PktWithWireRep
z = do
        (uidPkt, z1) <- String
-> Pkt
-> PacketZipper PktWithWireRep
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
consumePktZ String
"UID packet" (Text -> Pkt
UserIdPkt Text
uid) PacketZipper PktWithWireRep
z
        z2 <- tryMoveNext "missing UID" z1 (null rest && null sigs)
        (uidSigs, z3) <- consumeSigsZ "UID signature" sigs z2
        (tailUIDs, z4) <- consumeUIDsZ rest z3
        Right
            ( UIDWithWireRefs uid (packetRefIdOf uidPkt) uidSigs : tailUIDs
            , z4
            )

    consumeUAtsZ
        :: [([UserAttrSubPacket], [SignaturePayload])]
        -> PacketZipper PktWithWireRep
        -> Either String ([UAtWithWireRefs], PacketZipper PktWithWireRep)
    consumeUAtsZ :: [([UserAttrSubPacket], [SignaturePayload])]
-> PacketZipper PktWithWireRep
-> Either String ([UAtWithWireRefs], PacketZipper PktWithWireRep)
consumeUAtsZ [] PacketZipper PktWithWireRep
z = ([UAtWithWireRefs], PacketZipper PktWithWireRep)
-> Either String ([UAtWithWireRefs], PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right ([], PacketZipper PktWithWireRep
z)
    consumeUAtsZ (([UserAttrSubPacket]
uat, [SignaturePayload]
sigs) : [([UserAttrSubPacket], [SignaturePayload])]
rest) PacketZipper PktWithWireRep
z = do
        (uatPkt, z1) <- String
-> Pkt
-> PacketZipper PktWithWireRep
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
consumePktZ String
"UAt packet" ([UserAttrSubPacket] -> Pkt
UserAttributePkt [UserAttrSubPacket]
uat) PacketZipper PktWithWireRep
z
        z2 <- tryMoveNext "missing UAt" z1 (null rest && null sigs)
        (uatSigs, z3) <- consumeSigsZ "UAt signature" sigs z2
        (tailUats, z4) <- consumeUAtsZ rest z3
        Right
            ( UAtWithWireRefs uat (packetRefIdOf uatPkt) uatSigs : tailUats
            , z4
            )

    consumeSubsZ
        :: [(Pkt, [SignaturePayload])]
        -> PacketZipper PktWithWireRep
        -> Either String ([SubkeyWithWireRefs], PacketZipper PktWithWireRep)
    consumeSubsZ :: [(Pkt, [SignaturePayload])]
-> PacketZipper PktWithWireRep
-> Either
     String ([SubkeyWithWireRefs], PacketZipper PktWithWireRep)
consumeSubsZ [] PacketZipper PktWithWireRep
z = ([SubkeyWithWireRefs], PacketZipper PktWithWireRep)
-> Either
     String ([SubkeyWithWireRefs], PacketZipper PktWithWireRep)
forall a b. b -> Either a b
Right ([], PacketZipper PktWithWireRep
z)
    consumeSubsZ ((Pkt
subPkt, [SignaturePayload]
sigs) : [(Pkt, [SignaturePayload])]
rest) PacketZipper PktWithWireRep
z = do
        (subRef, z1) <- String
-> Pkt
-> PacketZipper PktWithWireRep
-> Either String (PktWithWireRep, PacketZipper PktWithWireRep)
consumePktZ String
"subkey packet" Pkt
subPkt PacketZipper PktWithWireRep
z
        z2 <- tryMoveNext "missing subkey" z1 (null rest && null sigs)
        (subSigs, z3) <- consumeSigsZ "subkey signature" sigs z2
        (tailSubs, z4) <- consumeSubsZ rest z3
        Right
            ( SubkeyWithWireRefs subPkt (packetRefIdOf subRef) subSigs
                : tailSubs
            , z4
            )

tksFromWireRep
    :: WireRepRef -> [TKWithWireRep] -> [TKWithWireRep]
tksFromWireRep :: WireRepRef -> [TKWithWireRep] -> [TKWithWireRep]
tksFromWireRep WireRepRef
src = (TKWithWireRep -> Bool) -> [TKWithWireRep] -> [TKWithWireRep]
forall a. (a -> Bool) -> [a] -> [a]
filter (WireRepRef -> [WireRepRef] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem WireRepRef
src ([WireRepRef] -> Bool)
-> (TKWithWireRep -> [WireRepRef]) -> TKWithWireRep -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WireRepRefs -> [WireRepRef]
forall a. NonEmpty a -> [a]
NE.toList (WireRepRefs -> [WireRepRef])
-> (TKWithWireRep -> WireRepRefs) -> TKWithWireRep -> [WireRepRef]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TKWithWireRep -> WireRepRefs
wireRepsOfTK)

tksContainingPacket
    :: PktWithWireRep -> [TKWithWireRep] -> [TKWithWireRep]
tksContainingPacket :: PktWithWireRep -> [TKWithWireRep] -> [TKWithWireRep]
tksContainingPacket PktWithWireRep
pkt = (TKWithWireRep -> Bool) -> [TKWithWireRep] -> [TKWithWireRep]
forall a. (a -> Bool) -> [a] -> [a]
filter (PktWithWireRep -> [PktWithWireRep] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem PktWithWireRep
pkt ([PktWithWireRep] -> Bool)
-> (TKWithWireRep -> [PktWithWireRep]) -> TKWithWireRep -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TKWithWireRep -> [PktWithWireRep]
packetRefsOfTK)

$(makeLenses ''TK)

type KeyringIxs = '[EightOctetKeyId, Fingerprint, Text]

-- | Kinded keyrings: homogeneous collections of public or secret TKs
type PublicKeyring = IxSet KeyringIxs (TK 'PublicTK)

type SecretKeyring = IxSet KeyringIxs (TK 'SecretTK)

type MixedKeyring = IxSet KeyringIxs (TK 'MixedTK)

-- | Parameterized kinded keyring for generic operations
type family KeyringOf (k :: TKKind) :: Type where
    KeyringOf 'PublicTK = PublicKeyring
    KeyringOf 'SecretTK = SecretKeyring
    KeyringOf 'MixedTK = MixedKeyring

$(makeLenses ''TKWithWireRep)
$(makeLenses ''PacketRefId)
$(makeLenses ''PacketZipper)
$(makeLenses ''SignatureWithWireRef)
$(makeLenses ''UIDWithWireRefs)
$(makeLenses ''UAtWithWireRefs)
$(makeLenses ''SubkeyWithWireRefs)
$(makeLenses ''TKStructuredWithWireRep)