3 ms·
I basically agree with this. I tend to adopt some mixture of the following: 1. Write the function and the type together, and use the type checker to perform an
by crntaylor 14y ago
I basically agree with this. I tend to adopt some mixture of the following:
1. Write the function and the type together, and use the type checker to perform an initial check for program correctness.
2. Write the function and the type, but comment out the type, and see if the type checker can infer something more general than the type you supplied.
3. Write the type but leave the function undefined - this gives you a skeleton of your project and lets you write both top-down and bottom-up at the same time, filling in the details later on.
4. Use a function, but leave it undefined and don't give it a type. The type checker can infer a type for it, which often helps you write the function itself.
5. Write the functions but not the type, and let the type checker figure the whole thing out (great for throwaway programs and scripting).
With combinations of these, and a brutal dedication to refactoring and modularisation, I find that I can quickly develop correct, re-usable code.