4 ms·
Unless what you're doing is content-agnostic String manipulation (i.e. a function to concatenate arbitrary Strings), this type signature wouldn't make sense. An
by dodobirdlord 7y ago
Unless what you're doing is content-agnostic String manipulation (i.e. a function to concatenate arbitrary Strings), this type signature wouldn't make sense. And since there are only a small number of meaningful content-agnostic string manipulations, I've already got a solid guess that this is probably doing concatenation! It could also possibly be doing substitution, or a few other things, but not much before it becomes a gaping code flaw that the types in use are still 'String'. Concatenating a person's name with a country name doesn't make sense. Nor does searching for a street address in a month. A type signature like String -> String-> String should only show up down in the implementation details of helper functions, or on the signatures of content-agnostic library functions.
- mpcjanssen 7y agoThis could equally well be a function which takes a string and a seed and returns the hash. The more concrete the type signatures become the less they become documenting. A signature of a -> a defines the id function because the type is so generic. A function of String->String can do pretty much anything.
- dodobirdlord 7y agoBut that's exactly my point. Why would something that is a randomization seed have type "String"? Why would a hash have type "String"? Why not type Seed and type Hash? A type signature of Seed -> String -> Hash is pretty enlightening!