# Lesson XX The sheet may serve the brush, or it may answer the question. ## Try ```prolog ?- E = kernel, infer(E, [when(int)], Scheme). Scheme = scheme([], effect([_|S], [bool|S])). ?- E = kernel, run(E, [push(int(4)), when(int)], [], Stack). Stack = [bool(true)]. ?- E = kernel, run(E, [push(bool(true)), when(int)], [], Stack). Stack = [bool(false)]. ``` ## Lesson `when/1` is a guard word over the existing literal/type boundary. The old representation already lets runtime ask what type a value has; this stage adds a word that exposes that test as a boolean result without changing the rest of execution. ```prolog apply(Env, when(Type), [Value|Rest], [bool(Bool)|Rest]) :- lit(Env, Value, Actual), ( Actual == Type -> Bool = true ; Bool = false ). infer1(_Env, when(_Type), effect([_Value|Rest], [bool|Rest]), Constraints, Constraints) :- !. ``` [[19_lesson|Prev]] | Next