Term_expansion not applied

term_expansion/2 is only called on the toplevel term. If you want to perform transformations inside the term you need to do so yourself. An intermediate step is provided by goal_expansion/2, which is called for each goal term in a clause.

Also note that term_expansion/2 is called only once per term, i.e., only the first answer of the expansion is used. goal_expansion/2 is called on the goal until fixed point is reached.

2 Likes