`tell_type` is an implicit generic procedure due to the `Foo|Bar`. That means for each encountered type for which it is used, a procedure taking that type will be generated.
Now, `if` is a runtime construct. So when you say `if ... is T` it's checking at runtime whether something is `T`. What you want to tell the compiler of course is to do this at compile time. That's what `when` is for. It's the compile time version of `if` essentially. Just replace `if` by `when` and it should work.