1:- module(ccreader, [ run_reader/3, ask/2 ]).
6:- use_module(library(delimcc), [p_reset/3, p_shift/2]). 7 8:- set_prolog_flag(generate_debug_info, false). 9 10ask(Pr,X) :- p_shift(Pr,X). 11 12:- meta_predicate run_reader( , , ).
16run_reader(Prompt, Goal, X) :- 17 p_reset(Prompt, Goal, Status), 18 cont_reader(Status, Prompt, X). 19 20cont_reader(done,_,_). 21cont_reader(susp(X,Cont), Prompt, X) :- run_reader(Prompt, Cont, X)
Essentially, direct style reader monad.
*/