Hacker News new | past | comments | ask | show | jobs | submit login

Haskell has the different semantics though they share the literal type. In Haskell there's Text for Unicode strings (UTF-16 encoded) and ByteString for, well, byte-strings (fixed vectors of Word8s). The semantics make it hard to confuse them, though if you turn on the OverloadedStrings extension then

    "foo"
is ambiguous. If you don't like that you can just not turn on that extension and then there is no literal syntax for either type and you must convert literal strings (really just lists of characters, [Char]) to either type manually

    Data.Text.pack "foo" :: Text
    Data.ByteString.pack "foo" :: ByteString
Finally, you must use manual encoding functions to interconvert them

    Data.Text.Encoding.encodeUtf8 :: Text -> ByteString



Python has separate bytes and unicode types as well, I think he meant there should be a "black box" type that the program shouldn't try to interpret.


I don't think you can really play the same game in Python. The idea of separation of types that occurs in Haskell will really require static typing. It means that entire processing pipelines in your code are completely specialized to one type of string or the other (or generalized to both) with no uncertainty.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: