Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

"pure" and "error" special forms - #367

Merged
jmcardon merged 1 commit into
masterfrom
jose/error-special
May 28, 2025
Merged

"pure" and "error" special forms#367
jmcardon merged 1 commit into
masterfrom
jose/error-special

Conversation

@jmcardon

@jmcardon jmcardon commented May 2, 2025

Copy link
Copy Markdown
Member

cc @CryptoPascal31

Supersedes #273 (Saves me a rebase).

Implements KIP 0024.

This PR adds two special forms into pact.

pure

(pure k) for some expression k will evaluate k in read-only mode. That is, the evaluation of k cannot write to the database, only read.

Example here

typing rule

  Γ ⊢ e : t
───────────────  (pure)
  Γ ⊢ (pure e) : t

Other notes

pure has been a community ask for a while, and allows users to use the power of try but without forcing users to write `(try (enforce false "boom") something)

error

(error foo) for some string valued expression foo (e.g "hello" or (format "{}" ["bar"])) will throw a recoverable error (so catchable with try).

Example here

typing rule

For some fresh α

  Γ ⊢ e : string
──────────────────────  (Error)
  Γ ⊢ (error e) : α

error in pact is essentially ⊥-elimination for pact. This is particularly useful for typechecking expressions where (enforce false will not suffice, as the return type of that is bool.

PR checklist:

  • Test coverage for the proposed changes
  • PR description contains example output from repl interaction or a snippet from unit test output
  • (If Relevant) Documentation has been (manually) updated at https://docs.kadena.io/pact

Additionally, please justify why you should or should not do the following:

  • Benchmark regressions
  • Confirm replay/back compat (Ignore until core release)
  • (For Kadena engineers) Run integration-tests against a Chainweb built with this version of Pact (Ignore until core release)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants