Skip to content

Instantly share code, notes, and snippets.

@aerohit
Created September 26, 2020 05:31
Show Gist options
  • Save aerohit/5de8b831eb59eeba329fc0615dac15a6 to your computer and use it in GitHub Desktop.
Save aerohit/5de8b831eb59eeba329fc0615dac15a6 to your computer and use it in GitHub Desktop.
Convert between String Text And ByteString
-- Reference: Ecky Putrady, Practical Web Development with Haskell, Table 2-1
String Text fromString
String LText fromString
String ByteString fromString
String LByteString fromString
Text LText fromStrict
Text ByteString encodeUtf8
Text LByteString (fromStrict . encodeUtf8)
Text String unpack
LText Text toStrict
LText ByteString (toStrict . encodeUtf8)
LText LByteString encodeUtf8
LText String unpack
ByteString LByteString fromStrict
ByteString Text decodeUtf8
ByteString LText (fromStrict . decodeUtf8)
ByteString String (unpack . decodeUtf8)
LByteString ByteString toStrict
LByteString Text (toStrict . decodeUtf8)
LByteString LText decodeUtf8
LByteString String (unpack . decodeUtf8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment