compact-core:compact-language-ref

Reference Compact language types, casting, operators, control flow, modules, and stdlib usage.

37|9|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-language-ref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compact-core:compact-language-ref
Source: https://github.com/devrelaicom/midnight-expert/tree/main/plugins/compact-core/skills/compact-language-ref
Command: npx skills add https://github.com/devrelaicom/midnight-expert --skill compact-core-compact-language-ref

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a clear, discoverable reference for the Compact language so developers can understand precise typing rules, casting behavior, operator semantics, control flow restrictions, module/import patterns, and standard library functions needed to write correct, provable circuits and avoid common compiler errors.

Core Features & Use Cases

  • Types & Casting: Explains primitive, opaque, collection, and custom types, literal typing, subtyping, and safe cast patterns with checked vs static casts.
  • Operators & Expressions: Clarifies arithmetic widening, boolean and relational operators, conditional expressions, and anonymous circuits used by map/fold.
  • Control Flow & Modules: Documents const-only bindings, for-loop unrolling and restrictions, if/else rules, pragma and include behavior, import forms, and export conventions for TypeScript interop.
  • Stdlib & Troubleshooting: Summarizes persistent vs transient hashing/commitments, disclose and assert semantics, pad/default utilities, and a wrong-to-correct compiler error quick reference for debugging.

Quick Start

Ask the skill to explain Compact types, casting rules, loop and disclosure restrictions, and key stdlib functions with practical wrong-to-correct examples and references to deeper documentation.

Frequently Asked Questions about compact-core:compact-language-ref

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix common compiler errors when writing Compact contracts?

Fix Compact compiler errors using wrong-to-correct examples for casting, control flow, and disclosure issues. The reference provides explicit rules and debugging quick fixes to correct typing mismatches and invalid loop unrolling constraints.

What are the casting and subtyping rules for the Compact language?

Compact casting rules define safe cast patterns using checked vs static casts for primitive, opaque, collection, and custom types. The reference explains literal typing and subtyping to ensure correct type behavior when authoring circuits.

How does control flow and for-loop unrolling work in Compact?

Compact control flow uses const-only bindings and restricts for-loop unrolling to compile-time constants. The reference documents if/else rules and loop constraints to help developers write provable circuits without runtime branching.

Can I use TypeScript interop and module imports in Compact contracts?

Compact supports TypeScript interop through export conventions, pragma directives, and include behavior. The reference details import forms and module patterns to structure contracts and integrate with TypeScript components correctly.

What standard library functions are available for hashing and commitments in Compact?

Compact stdlib provides persistent vs transient hashing, commitments, disclose and assert semantics, and pad/default utilities. The reference summarizes these functions to handle cryptographic operations and data availability in circuits.