I attended an excellent talk recently at Lambdale about teaching children to code (not just Scratch but actual computer languages) and one of the points of feedback was that the children found the use of names in type declarations and their corresponding implementations in languages such as Haskell confusing because frequently names are reused despite the two things being completely different categories of things.
The suggestion was that instead of
f[A] -> B it was simpler to say
f[AType] -> BType.
Since I am in the process of introducing Python type checking at work this immediately sparked some interest in me and when I returned to work I ran a quick survey with the team that revealed that they too preferred the explicit type name with the suffix
Type rather than package qualifier for types that I had been using.
kitchen_types.Kettle the preference was for
The corresponding function type annotations would therefore read approximately:
def boil(water: WaterType, kettle: KettleType) -> WaterType
So that’s the format we’re going to be adopting.
One thought on “Recommendation: use explicit type names”
I declare customerBalance as decimal to know its type for clarity. Reasonable alternatives might include double or even