diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-05 20:03:18 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-05 21:44:36 -0500 |
commit | 62d31ca46fb3143af3004730195ff6554cf3fa40 (patch) | |
tree | a2882c330ba580ef57ecbf62b999ae87d377e35d /dht/src/Codec | |
parent | 6047a311f270bbb0a176900d9b1fea5e6d9b96c1 (diff) |
Forward port to GHC 8.10.1-alpha2 (83edba07e4)
Diffstat (limited to 'dht/src/Codec')
-rw-r--r-- | dht/src/Codec/AsciiKey256.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/dht/src/Codec/AsciiKey256.hs b/dht/src/Codec/AsciiKey256.hs index ee17b7c1..1738a368 100644 --- a/dht/src/Codec/AsciiKey256.hs +++ b/dht/src/Codec/AsciiKey256.hs | |||
@@ -3,6 +3,7 @@ module Codec.AsciiKey256 where | |||
3 | 3 | ||
4 | import Control.Applicative | 4 | import Control.Applicative |
5 | import Control.Monad | 5 | import Control.Monad |
6 | import Control.Monad.Fail as MF | ||
6 | import Data.Bits | 7 | import Data.Bits |
7 | import qualified Data.ByteArray as BA | 8 | import qualified Data.ByteArray as BA |
8 | ;import Data.ByteArray as BA (ByteArrayAccess) | 9 | ;import Data.ByteArray as BA (ByteArrayAccess) |
@@ -112,7 +113,7 @@ readsPrecKey256 publicKey str | |||
112 | | otherwise = [] | 113 | | otherwise = [] |
113 | 114 | ||
114 | 115 | ||
115 | parseKey256 :: (Monad m, Alternative m) => String -> m ByteString | 116 | parseKey256 :: (MonadFail m, Alternative m) => String -> m ByteString |
116 | parseKey256 nidstr = do | 117 | parseKey256 nidstr = do |
117 | let nidbs = C8.pack nidstr | 118 | let nidbs = C8.pack nidstr |
118 | (bs,_) = Base16.decode nidbs | 119 | (bs,_) = Base16.decode nidbs |
@@ -121,7 +122,7 @@ parseKey256 nidstr = do | |||
121 | 43 -> parseToken32 nidstr | 122 | 43 -> parseToken32 nidstr |
122 | _ -> Left "Wrong size of key." | 123 | _ -> Left "Wrong size of key." |
123 | idbs <- (guard (B.length bs == 32) >> return bs) | 124 | idbs <- (guard (B.length bs == 32) >> return bs) |
124 | <|> either fail return enid | 125 | <|> either MF.fail return enid |
125 | return idbs | 126 | return idbs |
126 | 127 | ||
127 | readP_key256 :: RP.ReadP ByteString | 128 | readP_key256 :: RP.ReadP ByteString |
@@ -131,7 +132,7 @@ readP_key256 = do | |||
131 | , fmap (32,) (sequence $ replicate 52 (RP.satisfy zb32digit)) | 132 | , fmap (32,) (sequence $ replicate 52 (RP.satisfy zb32digit)) |
132 | , fmap (64,) (sequence $ replicate 43 (RP.satisfy b64digit)) | 133 | , fmap (64,) (sequence $ replicate 43 (RP.satisfy b64digit)) |
133 | ] | 134 | ] |
134 | let failure = fail "Bad key." | 135 | let failure = MF.fail "Bad key." |
135 | case is64 of | 136 | case is64 of |
136 | 32 -> case parse32Token32 hexhash of | 137 | 32 -> case parse32Token32 hexhash of |
137 | Right bs -> return bs | 138 | Right bs -> return bs |