Since the old Debug.crash
was replaced by Debug.todo
the intention is clear that this is made for development purposes. And in that sense it is extremely useful when prototyping or making top-down progress on some code. The idea being that as long as your scenario does not get in the todo branch, you can make progress and test your progress in your app. This assumption breaks however as soon as Debug.todo
is used for a constant.
module ToBeDone exposing (complicatedCode)
complicatedCode bool =
if bool then
"happy path"
else
tbd
tbd =
Debug.todo "Constant not coded yet"
Whatever you do with the above code, even if you never call complicatedCode False
it will crash at the start of the application. This is because tbd
is a constant and thus evaluated on start.
I have a use case for teaching material where we provide a template files containing Debug.todo
s and a test file checking that the todos are replaced with valid code. But if we have a Debug.todo
for one of those constants like we used to have here, elm-test would crash instead of reporting a failure for the test calling the todo constant, which is not very convenient for learning material.
I’d love if it would be possible to have constant Debug.todo
that behave like for functions, crashing only when called.