Or potentially some kind of syntax like:
assert_type(Thing, Func/Arity) ...
assert_type(Expected, Term) :-
( Expected = Functor/Arity
-> assert_type(Term, Functor, Arity)
; call_protected(
type_matches(Expected, Term),
fail_assert_type(Expected, Term)
)
).