-
Notifications
You must be signed in to change notification settings - Fork 10
typecheck: Minor doc updates for consistency with other functions #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,54 @@ | ||
## typecheck | ||
|
||
Use `(typecheck "my-module")` to run the pact static typechecker on some module `my-module` | ||
Use `typecheck` to run the Pact static type checker on the `module` you specify. | ||
|
||
### Basic syntax | ||
|
||
For some module `foo`: | ||
To run the static type checker on the `module` specified, use the following syntax: | ||
|
||
```pact | ||
(module foo GOV | ||
(defcap GOV () true) | ||
|
||
(defun plus-one (a) (+ a 1)) | ||
) | ||
``` | ||
|
||
To statically typecheck `foo`, call | ||
|
||
```pact | ||
(typecheck "foo") | ||
(typecheck module) | ||
``` | ||
|
||
If your module `foo` is under `(namespace "bar)`, then call `(typecheck "bar.foo")` | ||
|
||
## Arguments | ||
### Arguments | ||
|
||
Use the following arguments when calling `typecheck`: | ||
Use the following argument when calling the `typecheck` function: | ||
|
||
| Argument | Type | Description | | ||
|----------|------|-------------| | ||
| `module` | string | The module to run the static typechecker on | | ||
| `module` | string | Specifies the name of the module to run the static type checker on. | | ||
|
||
## Return value | ||
### Return value | ||
|
||
On typechecking succeess, `typecheck` returns the unit value `()`. Otherwise, it will throw an error. | ||
If type checking for the module is successful, the `typecheck` function returns the unit value `()`. | ||
If type checking fails, the `typecheck` function throws an error and ends execution. | ||
|
||
## Examples | ||
### Examples | ||
|
||
The following example demonstrates how to call the static typechecker: | ||
|
||
|
||
For some module `foo`: | ||
The following example demonstrates a simple `.repl` file with the module declaration for a `rewards` module that then calls the static type checker to check the `rewards` module: | ||
|
||
```pact | ||
(module foo GOV | ||
(module rewards GOV | ||
(defcap GOV () true) | ||
|
||
(defun plus-one (a) (+ a 1)) | ||
(defun multiplier (points) (* points 10)) | ||
) | ||
|
||
(typecheck "foo") | ||
(typecheck "rewards") | ||
``` | ||
|
||
If you execute the code in the file by running `pact rewards.repl --trace`, you see the results of type checking for the module. | ||
For example: | ||
|
||
```bash | ||
rewards.repl:0:0-4:1:Trace: Loaded module rewards, hash d6qkp1SyjmFCUofnsMpdV2W3IOLH8VA9lg0Dqv4cN_M | ||
rewards.repl:6:0-6:21:Trace: Typechecking successful for module rewards | ||
Load successful | ||
``` | ||
|
||
If you specify a namespace before the module declaration, you must include the namespace when you call the `typecheck` function. | ||
For example, if the `rewards` module declaration comes after entering the `(namespace "develop")` namespace, you would call the `typecheck` function like this: | ||
|
||
```pact | ||
(typecheck "develop.rewards") | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.