Advertisement
NLinker

Haskell string conversions

Jul 28th, 2017
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.ByteString.Lazy as BL
  2. import Data.ByteString as BS
  3. import Data.Text as TS
  4. import Data.Text.Lazy as TL
  5. import Data.ByteString.Lazy.UTF8 as BLU
  6. import Data.ByteString.UTF8 as BSU
  7. import Data.Text.Encoding as TSE
  8. import Data.Text.Lazy.Encoding as TLE
  9.  
  10. -- String <-> ByteString
  11.  
  12. BLU.toString   :: BL.ByteString -> String
  13. BLU.fromString :: String -> BL.ByteString
  14. BSU.toString   :: BS.ByteString -> String
  15. BSU.fromString :: String -> BS.ByteString
  16.  
  17. -- String <-> Text
  18.  
  19. TL.unpack :: TL.Text -> String
  20. TL.pack   :: String -> TL.Text
  21. TS.unpack :: TS.Text -> String
  22. TS.pack   :: String -> TS.Text
  23.  
  24. -- ByteString <-> Text
  25.  
  26. TLE.encodeUtf8 :: TL.Text -> BL.ByteString
  27. TLE.decodeUtf8 :: BL.ByteString -> TL.Text
  28. TSE.encodeUtf8 :: TS.Text -> BS.ByteString
  29. TSE.decodeUtf8 :: BS.ByteString -> TS.Text
  30.  
  31. -- Lazy <-> Strict
  32.  
  33. BL.fromStrict :: BS.ByteString -> BL.ByteString
  34. BL.toStrict   :: BL.ByteString -> BS.ByteString
  35. TL.fromStrict :: TS.Text -> TL.Text
  36. TL.toStrict   :: TL.Text -> TS.Text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement