/**
 * This module provides a basic strategy for specifying
 * run-time verified strategies.
 *
 * @author Lennart Kats <lennart add lclnet.nl>
 */
module lang/with

imports
  util/log
  strategy/conditional

strategies

  /**
   * Evaluate a strategy s, or, if s fails, end with a fatal error.
   *
   * @note In future revisions, a facility may be provided to "catch"
   *       failures raised by with clauses and uses of this strategy.
   */
  with(s|message) =
    where(s <+ report-with-failure(|message, <prim("SSL_stacktrace_get_all_frame_names")>))
  
  /**
   * @obsolete
   * @internal
   */
  report-with-failure(|message) =
      ?term
    ; prim("SSL_stacktrace_get_all_frame_names")
    ; report-failure(log(|Critical(), message, term); exit)
  
  /**
   * @internal
   */
  report-with-failure(|message, trace) =
      ?term
    ; !trace
    ; report-failure(log(|Critical(), message, term); exit)