Skip to content

Commit 27d58e2

Browse files
committed
fix base16-bytestring
1 parent fd4634e commit 27d58e2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pub/functora/src/bolt11/Functora/Bolt11.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE BangPatterns #-}
2+
{-# LANGUAGE CPP #-}
23

34
module Functora.Bolt11
45
( Bolt11 (..),
@@ -42,10 +43,21 @@ instance Show Hex where
4243
instance IsString Hex where
4344
fromString =
4445
Hex
45-
. either error id
46+
. handler
4647
. B16.decode
4748
. T.encodeUtf8
4849
. 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
4961

5062
data Tag
5163
= PaymentHash Hex

0 commit comments

Comments
 (0)