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

Right, but I don't think this sort of type "conversion" (e.g. some function with type signature like this in Haskell)

    escapeQueryString :: ByteString -> Query
is really adding or throwing away type information, it's just a function that accepts one type and returns another type. So it's not related to casting, except that it's the opposite of casting. But what that gives you is the ability to compose it with any other function that you define as accepting a `Query` type, and the program will refuse to compile if you ever accidentally try to pass it a ByteString. So it's about enforcing an invariant, in other words.



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

Search: