We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd4634e commit 27d58e2Copy full SHA for 27d58e2
pub/functora/src/bolt11/Functora/Bolt11.hs
@@ -1,4 +1,5 @@
1
{-# LANGUAGE BangPatterns #-}
2
+{-# LANGUAGE CPP #-}
3
4
module Functora.Bolt11
5
( Bolt11 (..),
@@ -42,10 +43,21 @@ instance Show Hex where
42
43
instance IsString Hex where
44
fromString =
45
Hex
- . either error id
46
+ . handler
47
. B16.decode
48
. T.encodeUtf8
49
. T.pack
50
+ where
51
+#if MIN_VERSION_base16_bytestring(1,0,0)
52
+ handler :: Either String ByteString -> ByteString
53
+ handler =
54
+ either error id
55
+#else
56
+ handler :: (ByteString, ByteString) -> ByteString
57
+ handler = \case
58
+ (success, "") -> success
59
+ failure -> error $ "Non-Hex bytestring " <> show failure
60
+#endif
61
62
data Tag
63
= PaymentHash Hex
0 commit comments