From fd70a681dc6df30bbd7c019931feff8c024bdbd3 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Mon, 5 Feb 2024 20:42:22 -0600 Subject: [PATCH] Add `fromText` function --- src/Data/HexString.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/HexString.hs b/src/Data/HexString.hs index 273a70a..f0b5d79 100644 --- a/src/Data/HexString.hs +++ b/src/Data/HexString.hs @@ -80,6 +80,10 @@ fromBytes = hexString . BS16.encode toBytes :: HexString -> BS.ByteString toBytes (HexString bs) = BS16.decodeLenient bs +-- | Reads a human-readable hex string into a `HexString` +fromText :: T.Text -> HexString +fromText = hexString . TE.encodeUtf8 + -- | Access to a 'T.Text' representation of the 'HexString' toText :: HexString -> T.Text toText (HexString bs) = TE.decodeUtf8 bs