Exercises in Programming Style–Declared Intentions

NOTE : read the rest of the series, or check out the source code.

If you enjoy read­ing these exer­cises then please buy Crista’s book to sup­port her work.


Fol­low­ing on from the last post, we will look at the Declared Inten­tions style today.


Style 23 – Declared Intentions


  • Exis­tence of a run-time type­check­er.
  • Pro­ce­dures and func­tions declare what types of argu­ments they expect.
  • If callers send argu­ments of types that aren’t expect­ed, the procedures/functions are not exe­cut­ed.


The prob­lem of type check­ing is a solved prob­lem in sta­t­i­cal­ly typed lan­guages, so by pro­gram­ming in F# there’s almost noth­ing we need to real­ly do for this style.

Using the same solu­tion from the Pipeline (aka func­tion­al) style, I have added a few explic­it type dec­la­ra­tions to bet­ter com­ply with the con­straints.



You can find the source code for this exer­cise here.