What to do with | prompt in REPL

Reposted from this post by Jan W.

The | prompt is a continuation prompt telling you the input is incomplete. So, you can just keep typing, e.g.

?- <return>
|  write(hello).
hello
true.
?- 

Another popular trick if you use , (comma) rather than . (dot) by accident is to add true. , e.g.,

?- write(hello),
|  true.
hello
true.
?- 

On some installations pressing ^C (control C) and a (abort) also works. It depends on the input method (plain terminal, GNU readline, BSD libedit, embedding in Emacs, ECliPSe, etc.).