I tend to like programming in a style where I can be very explicit about the types of expressions. While Mathematica isn't and shouldn't be a strongly-typed language like Haskell, I think it would sometimes be helpful to define a function that will explicitly reject inputs of an incorrect type.
I'm aware I can do something like
f[x_List] := x + 1 In[39]:= f[1] Out[39]= f[1] In[40]:= f[{1, 1}] Out[40]= {2, 2} This will prevent the pattern from matching on invalid arguments, but it will just propagate the unevaluated expression forward in other computations. However, I'd like to sometimes give myself stronger guarantees. I would like a function that matches on all input expressions, and errors if they fail to match some pattern. And I'd like to do it, if possible, in a way that minimizes boilerplate. Is there already an idiomatic way to do this?