StdDebug.dcl 1.53 KB
Newer Older
1 2
definition module StdDebug

Camil Staps's avatar
Camil Staps committed
3 4 5 6
/**
 * Functions that write intermediate results to stderr for debugging purposes.
 */

7 8 9 10 11 12 13 14 15 16 17 18
// ********************************************************
//	Concurrent Clean Standard Library Module Version 2.0
//	Copyright 1998 University of Nijmegen
// ********************************************************

import StdClass

from StdString import instance toString	{#Char},instance toString Int

// The following functions should only be used for debugging,
// because these functions have side effects

Camil Staps's avatar
Camil Staps committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/**
 * Write a message to stderr before returning a value.
 *
 * @param The message to write to stderr
 * @param The value to return
 * @result Param 2
 */
trace :: !msg .a -> .a | toString msg special msg={#Char}; msg=Int

/**
 * Write a message and a newline to stderr before returning a value.
 *
 * @param The message to write to stderr
 * @param The value to return
 * @result Param 2
 */
trace_n :: !msg .a -> .a | toString msg special msg={#Char}; msg=Int

/**
 * Write a message to stderr and return True. This is useful in guards, for
 * example:
 *
 * ```
 * square x
 * | trace_t x = x * x
 * ```
 *
 * @param The message to write to stderr
 * @result True
 */
trace_t :: !msg -> Bool | toString msg special msg={#Char}; msg=Int

/**
 * Write a message and a newline to stderr and return True. This is useful in
 * guards, for example:
 *
 * ```
 * square x
 * | trace_tn x = x * x
 * ```
 *
 * @param The message to write to stderr
 * @result True
 */
trace_tn :: !msg -> Bool | toString msg special msg={#Char}; msg=Int