@@ -40,8 +40,7 @@ import qualified Data.ByteString as BS
40
40
import qualified Data.ByteString.Base16 as B16
41
41
import qualified Data.ByteString.Builder as BS
42
42
import qualified Data.ByteString.Lazy.Char8 as BL
43
- import qualified Data.Text as T
44
- import qualified Data.Text.Encoding as T
43
+ import qualified Data.Text.Lazy as TL
45
44
import Functora.Prelude hiding (error )
46
45
import Prelude (Show (.. ), error )
47
46
@@ -51,12 +50,13 @@ newtype Hex = Hex
51
50
deriving stock (Eq , Ord , Data , Generic )
52
51
53
52
instance Show Hex where
54
- show = inspectHex
53
+ show =
54
+ from @ TL. Text @ String
55
+ . inspectHex
55
56
56
- inspectHex :: forall a . ( From String a ) => Hex -> a
57
+ inspectHex :: Hex -> TL. Text
57
58
inspectHex =
58
- from @ String @ a
59
- . BL. unpack
59
+ decodeUtf8
60
60
. BS. toLazyByteString
61
61
. BS. byteStringHex
62
62
. unHex
@@ -66,8 +66,7 @@ instance IsString Hex where
66
66
Hex
67
67
. handler
68
68
. B16. decode
69
- . T. encodeUtf8
70
- . T. pack
69
+ . encodeUtf8 @ String @ ByteString
71
70
where
72
71
#if MIN_VERSION_base16_bytestring(1,0,0)
73
72
handler :: Either String ByteString -> ByteString
@@ -126,20 +125,18 @@ data FeatureName
126
125
| Unknown_feature
127
126
deriving stock (Eq , Ord , Show , Data , Generic )
128
127
129
- inspectFeature :: forall a . (From Text a ) => Feature -> a
128
+ inspectFeature :: forall a . (Textual a ) => Feature -> a
130
129
inspectFeature x =
131
- from @ Text @ a
132
- $ " ("
130
+ " ("
133
131
<> inspect (featureBits x)
134
132
<> " ) "
135
- <> T. toLower (inspect $ featureName x)
133
+ <> toLower (inspect $ featureName x)
136
134
<> " "
137
- <> T. toLower (inspect $ featureRequiredOrSuported x)
135
+ <> toLower (inspect $ featureRequiredOrSuported x)
138
136
139
- inspectFeatures :: forall a . ( From Text a ) => [Feature ] -> a
137
+ inspectFeatures :: ( Textual a ) => [Feature ] -> a
140
138
inspectFeatures =
141
- from @ Text @ a
142
- . T. intercalate " , "
139
+ intercalate " , "
143
140
. fmap inspectFeature
144
141
145
142
parseFeatures :: [Word5 ] -> [Feature ]
@@ -211,18 +208,18 @@ data Route = Route
211
208
instance A. ToJSON Route where
212
209
toJSON x =
213
210
A. object
214
- [ " pubkey" A. .= inspectHex @ Text (routePubKey x),
215
- " short_channel_id" A. .= inspectHex @ Text (routeShortChanId x),
211
+ [ " pubkey" A. .= inspectHex (routePubKey x),
212
+ " short_channel_id" A. .= inspectHex (routeShortChanId x),
216
213
" fee_base_msat" A. .= routeFeeBaseMsat x,
217
214
" fee_proportional_millionths" A. .= routeFeePropMillionth x,
218
215
" cltv_expiry_delta" A. .= routeCltvExpiryDelta x
219
216
]
220
217
toEncoding x =
221
218
A. pairs
222
219
$ " pubkey"
223
- A. .= inspectHex @ Text (routePubKey x)
220
+ A. .= inspectHex (routePubKey x)
224
221
<> " short_channel_id"
225
- A. .= inspectHex @ Text (routeShortChanId x)
222
+ A. .= inspectHex (routeShortChanId x)
226
223
<> " fee_base_msat"
227
224
A. .= routeFeeBaseMsat x
228
225
<> " fee_proportional_millionths"
0 commit comments