News for hackers. Stuff that matters.
Re:Implement with Types, Not Your Brain by quickthrower2 on Tuesday June 25, 2019 @07:45PM (#20280449)
What about String -> String-> String ?
Re:Implement with Types, Not Your Brain by dodobirdlord on Wednesday June 26, 2019 @02:13AM (#20282328)
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.
Re:Implement with Types, Not Your Brain by mpcjanssen on Wednesday June 26, 2019 @10:01AM (#20285075)
This 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.

Re:Implement with Types, Not Your Brain by dodobirdlord on Wednesday June 26, 2019 @10:16PM (#20291203)
But 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!