2 Language Concepts

This section documents the language forms in Pyret, as well as a number of Pyret-specific libraries and concepts, like Testing and Equality.

    2.1 Language Constructs

      2.1.1 Primitives and Literals

        2.1.1.1 Names

        2.1.1.2 String Literals

        2.1.1.3 Number Literals

        2.1.1.4 Boolean Literals

      2.1.2 Comments

      2.1.3 Programs

      2.1.4 Import Statements

      2.1.5 Provide Statements

      2.1.6 Bindings

        2.1.6.1 Name bindings

        2.1.6.2 Annotated bindings

        2.1.6.3 Shadowing

        2.1.6.4 Tuple bindings

      2.1.7 Blocks

        2.1.7.1 Block Shorthand

      2.1.8 Declarations

        2.1.8.1 Let Declarations

        2.1.8.2 Recursive Let Declarations

        2.1.8.3 Function Declaration Expressions

          2.1.8.3.1 Scope

          2.1.8.3.2 Where blocks

          2.1.8.3.3 Syntactic sugar

        2.1.8.4 Data Declarations

        2.1.8.5 Variable Declarations

        2.1.8.6 Type Declarations

        2.1.8.7 Newtype Declarations

      2.1.9 Contracts

      2.1.10 Statements

        2.1.10.1 When Statements

        2.1.10.2 Assignment Statements

        2.1.10.3 Binop Expression “Statements”

      2.1.11 Expressions

        2.1.11.1 Lambda Expressions

        2.1.11.2 Curly-Brace Lambda Shorthand

        2.1.11.3 Anonymous Method Expressions

        2.1.11.4 Application Expressions

        2.1.11.5 Curried Application Expressions

        2.1.11.6 Chaining Application

        2.1.11.7 Instantiation Expressions

        2.1.11.8 Binary Operators

        2.1.11.9 Tuple Expressions

        2.1.11.10 Tuple Access Expressions

        2.1.11.11 Object Expressions

        2.1.11.12 Dot Expressions

        2.1.11.13 Extend Expressions

        2.1.11.14 If Expressions

        2.1.11.15 Ask Expressions

        2.1.11.16 Cases Expressions

        2.1.11.17 For Expressions

        2.1.11.18 Template (...) Expressions

        2.1.11.19 Tables

          2.1.11.19.1 Sorting Table Rows

          2.1.11.19.2 Transforming Table Rows

          2.1.11.19.3 Extracting Table Columns

          2.1.11.19.4 Adding Table Columns

        2.1.11.20 Table Loading Expressions

        2.1.11.21 Reactor Expressions

        2.1.11.22 Mutable fields

        2.1.11.23 Construction expressions

        2.1.11.24 Expression forms of bindings

      2.1.12 Annotations

        2.1.12.1 Name Annotations

        2.1.12.2 Parametric Annotations

        2.1.12.3 Arrow Annotations

        2.1.12.4 Predicate Annotations

        2.1.12.5 Tuple Annotations

        2.1.12.6 Record Annotations

    2.2 Testing

      2.2.1 check: and where: blocks

        2.2.1.1 check: blocks

        2.2.1.2 where: blocks

      2.2.2 Testing Operators

        2.2.2.1 Binary Test Operators

        2.2.2.2 Unary Test Operators

        2.2.2.3 Exception Test Operators

    2.3 equality

      2.3.1 Types of Equality

      2.3.2 Equal Now

        2.3.2.1 Equal Now and Primitives

        2.3.2.2 Equal Now and Structured Data

        2.3.2.3 Equal Now and References

      2.3.3 Identical

        2.3.3.1 Identical and Primitives

        2.3.3.2 Identical and Structural Equality

        2.3.3.3 Identical and Mutable Data

      2.3.4 Always Equal

        2.3.4.1 Always Equal and Mutable Data

      2.3.5 Properties of Equality Functions

      2.3.6 Bounded Equalities

      2.3.7 Undefined Equalities

        2.3.7.1 Roughnums and Equality

        2.3.7.2 Functions and Equality

      2.3.8 Total Equality Functions (Avoiding Incomparability Errors)

      2.3.9 Datatype-defined Equality

      2.3.10 Inequalities

    2.4 Operator Precedence

    2.5 Brands

    2.6 Type Checking

      2.6.1 Required Annotations

      2.6.2 Working with Data Types

      2.6.3 Record Types

    2.7 Spies

      2.7.1 Examples

      2.7.2 Minor Notes and Corner Cases

      2.7.3 Grammar

      2.7.4 Rationale