From e69f4750ceb30ba6e1953ce746d00ad4bc89145f Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 2 Jul 2019 03:50:22 -0400 Subject: Make KeyKey a proper type. --- lib/KeyRing/Types.hs | 5 +++-- lib/PacketTranscoder.hs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/KeyRing/Types.hs b/lib/KeyRing/Types.hs index e1e19f5..f5fd879 100644 --- a/lib/KeyRing/Types.hs +++ b/lib/KeyRing/Types.hs @@ -299,10 +299,11 @@ data InputFileContext = InputFileContext -- which is used for finger-printing and as a lookup key into -- maps. This type may be changed to an actual fingerprint in -- in the future. -type KeyKey = [(Char,MPI)] +newtype KeyKey = KeyKey [(Char,MPI)] + deriving (Eq,Ord,Show) keykey :: Packet -> KeyKey -keykey k = concatMap (\c -> (maybeToList $ find (\(f,x) -> f==c) (key k))) (public_key_fields $ key_algorithm k) +keykey k = KeyKey $ concatMap (\c -> (maybeToList $ find (\(f,x) -> f==c) (key k))) (public_key_fields $ key_algorithm k) isKey :: Packet -> Bool isKey (PublicKeyPacket {}) = True diff --git a/lib/PacketTranscoder.hs b/lib/PacketTranscoder.hs index 6eadfe4..eaed938 100644 --- a/lib/PacketTranscoder.hs +++ b/lib/PacketTranscoder.hs @@ -315,8 +315,12 @@ keyQueries grip ringPackets = (mwk, fmap makeQuery keys) m2 :: Map.Map KeyKey (Maybe Packet, MappedPacket, (Map.Map String [Packet])) m2 = Map.fromList $ drop 1 - $ scanl' build ([],(Nothing,error "bug in PacketTranscoder (1)", error "bug in PacketTranscoder (2)")) pss + $ scanl' build failure pss where + failure = ( error "bug in PacketTranscoder(3)" + , (Nothing,error "bug in PacketTranscoder (1)" + , error "bug in PacketTranscoder (2)") + ) build (_,(main0,_,_)) ps = (kk,(main,kp,uidmap ps')) where main | is_subkey (packet kp) = main0 -- cgit v1.2.3