Skip to content

Commit 5d86044

Browse files
committed
Minor updates for consistency with other functions
1 parent 44d3ebf commit 5d86044

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

docs/builtins/Repl/typecheck.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
1-
## typecheck
1+
# typecheck
22

3-
Use `(typecheck "my-module")` to run the pact static typechecker on some module `my-module`
3+
Use `typecheck` to run the Pact static type checker on a specified `module` name.
44

5-
### Basic syntax
5+
## Basic syntax
66

7-
For some module `foo`:
7+
To run the static type checker on a specified `module` name, use the following syntax:
88

99
```pact
10-
(module foo GOV
11-
(defcap GOV () true)
12-
13-
(defun plus-one (a) (+ a 1))
14-
)
15-
```
16-
17-
To statically typecheck `foo`, call
18-
19-
```pact
20-
(typecheck "foo")
10+
(typecheck module)
2111
```
2212

23-
If your module `foo` is under `(namespace "bar)`, then call `(typecheck "bar.foo")`
24-
2513
## Arguments
2614

27-
Use the following arguments when calling `typecheck`:
15+
Use the following argument when calling the `typecheck` function:
2816

2917
| Argument | Type | Description |
3018
|----------|------|-------------|
31-
| `module` | string | The module to run the static typechecker on |
19+
| `module` | string | Specifies the name of the module to run the static type checker on. |
3220

3321
## Return value
3422

35-
On typechecking succeess, `typecheck` returns the unit value `()`. Otherwise, it will throw an error.
23+
If type checking for the module is successful, the `typecheck` function returns the unit value `()`.
24+
If type checking fails, the function returns an error.
3625

3726
## Examples
3827

39-
The following example demonstrates how to call the static typechecker:
40-
41-
42-
For some module `foo`:
28+
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:
4329

4430
```pact
45-
(module foo GOV
31+
(module rewards GOV
4632
(defcap GOV () true)
4733
48-
(defun plus-one (a) (+ a 1))
34+
(defun multiplier (points) (* points 10))
4935
)
5036
51-
(typecheck "foo")
37+
(typecheck "rewards")
38+
```
39+
40+
If you execute the code in the file by running `pact rewards.repl --trace`, you see the results of type checking for the module.
41+
For example:
42+
43+
```bash
44+
rewards.repl:0:0-4:1:Trace: Loaded module rewards, hash d6qkp1SyjmFCUofnsMpdV2W3IOLH8VA9lg0Dqv4cN_M
45+
rewards.repl:6:0-6:21:Trace: Typechecking successful for module rewards
46+
Load successful
5247
```
48+
49+
If you specify a namespace before the module declaration, you must include the namespace when you call the `typecheck` function.
50+
For example, if the `rewards` module declaration comes after entering the `(namespace "develop")` namespace, you would call the `typecheck` function like this:
51+
52+
```pact
53+
(typecheck "develop.rewards")
54+
```

0 commit comments

Comments
 (0)