Is this a parody? I can read the c# version and immediately see what it does in the event of missing values, verbose as it is. If the monadic version were part of a real program, longer than 10 lines, I would have no idea what’s happening without flipping here and there through the source. Is that really an aid to understanding?
No. He shows steps along the way towards the design, but the monadic version would be only the last block of code, which includes type definitions that the C# lacks matching class definitions for. The final version really is just:
let revenue (energy: float<MW h>)
(price: float<``£``>)
(factor: float) =
energy * price * factor
and the monadic use is a compiler-enforced common idiom that would be recognized by any F# coder rather than a null check waiting to be forgotten.
It has a weird V-like feeling to me. Starts from verbose, boilerplate-heavy code. Boils it down to short, simple code. Then expands it again to verbose, boilerplate-heavy code.
Is this a parody? I can read the c# version and immediately see what it does in the event of missing values, verbose as it is. If the monadic version were part of a real program, longer than 10 lines, I would have no idea what’s happening without flipping here and there through the source. Is that really an aid to understanding?
No. He shows steps along the way towards the design, but the monadic version would be only the last block of code, which includes type definitions that the C# lacks matching class definitions for. The final version really is just:
and the monadic use is a compiler-enforced common idiom that would be recognized by any F# coder rather than a null check waiting to be forgotten.
It has a weird V-like feeling to me. Starts from verbose, boilerplate-heavy code. Boils it down to short, simple code. Then expands it again to verbose, boilerplate-heavy code.