-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `debug` function is a utility designed to aid in debugging specifications by allowing the spec developer to print out a contextual message while executing a specification, whether in a run or in a test, along with a formatted representation of a value. This can be useful when trying to understand the state of variables at specific points during the spec execution or while tracking down issues. The `debug` function has the following signature: ``` def debug(header: str, value: a) -> a ``` The `debug` function prints both header and the value on the same line, preceded by a `>` character, and then returns the given value, which makes it easy to debug nested expressions without having the extract them into a variable first. Example usage in the REPL: ``` >>> debug("a number:", 42) > a number: 42 42 >>> debug("a record:", { foo: 32, bar: true }) > a record: { bar: true, foo: 32 } { bar: true, foo: 32 } >>> debug("large record:", largeRecord) > large record: { hello: { world: { foo: { bar: { baz: 42 }, toto: { tata: { tutu: "Hello, World" } } } } } } { hello: { world: { foo: { bar: { baz: 42 }, toto: { tata: { tutu: "Hello, World" } } } } } } >>> if (a * debug("nested", a + b) == 10) true else false > nested 5 true ```
- Loading branch information
Showing
6 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters