summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2013-01-01 13:11:44 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2013-01-01 13:11:44 -0500
commite5d953a676a9077ff03fd9222083ab696de711a3 (patch)
tree90b77c4a7f09574b14d87972b0eaad2e7d2b89bb
parent9e4f996c68c3901bab4a5e1e70638c2531a85994 (diff)
No more fromJust
-rw-r--r--Data/OpenPGP.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 5e62d1a..266cd9b 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -68,7 +68,6 @@ import Control.Applicative
68import Data.Bits 68import Data.Bits
69import Data.Word 69import Data.Word
70import Data.Char 70import Data.Char
71import Data.Maybe
72import Data.List 71import Data.List
73import Data.OpenPGP.Internal 72import Data.OpenPGP.Internal
74import qualified Data.ByteString.Lazy as LZ 73import qualified Data.ByteString.Lazy as LZ
@@ -326,7 +325,7 @@ secret_key_fields DSA = ['x']
326secret_key_fields _ = undefined -- Nothing in the spec. Maybe empty 325secret_key_fields _ = undefined -- Nothing in the spec. Maybe empty
327 326
328(!) :: (Eq k) => [(k,v)] -> k -> v 327(!) :: (Eq k) => [(k,v)] -> k -> v
329(!) xs = fromJust . (`lookup` xs) 328(!) xs k = let Just x = lookup k xs in x
330 329
331-- Need this seperate for trailer calculation 330-- Need this seperate for trailer calculation
332signature_packet_start :: Packet -> B.ByteString 331signature_packet_start :: Packet -> B.ByteString
@@ -461,7 +460,7 @@ put_packet p@(PublicKeyPacket { version = v, timestamp = timestamp,
461 | v == 3 = 460 | v == 3 =
462 final (B.concat $ [ 461 final (B.concat $ [
463 B.singleton 3, encode timestamp, 462 B.singleton 3, encode timestamp,
464 encode (fromJust $ v3_days_of_validity p), 463 encode v3_days,
465 encode algorithm 464 encode algorithm
466 ] ++ material) 465 ] ++ material)
467 | v == 4 = 466 | v == 4 =
@@ -469,6 +468,7 @@ put_packet p@(PublicKeyPacket { version = v, timestamp = timestamp,
469 B.singleton 4, encode timestamp, encode algorithm 468 B.singleton 4, encode timestamp, encode algorithm
470 ] ++ material) 469 ] ++ material)
471 where 470 where
471 Just v3_days = v3_days_of_validity p
472 final x = (x, if is_subkey then 14 else 6) 472 final x = (x, if is_subkey then 14 else 6)
473 material = map (encode . (key !)) (public_key_fields algorithm) 473 material = map (encode . (key !)) (public_key_fields algorithm)
474put_packet (CompressedDataPacket { compression_algorithm = algorithm, 474put_packet (CompressedDataPacket { compression_algorithm = algorithm,