On this page:
Generic Relations
8.12

Generic Relations🔗ℹ

Siddhartha Kasivajhula

 (require relation) package: relation-lib

This collection provides generic relations and type-agnostic operators. Out of the box, many Racket relations and operators are type-specific. For instance, < operates specifically on numbers, conversion of any datatype to a string must use a type-specific transformer like symbol->string, and likewise + operates specifically on numbers even though many datatypes sustain a natural notion of addition. This package provides a number of interfaces and utilities to override these default operators with generic versions. With a few exceptions, the generic operators provided in this collection are drop-in alternatives to the built-in ones.

Read the blog post introducing this library: What Should + Mean in Programming Languages?

    1 Logical Relations

    2 Types

      2.1 Constructors

      2.2 Transformers

    3 Equivalence Relations

      3.1 Interface

      3.2 Utilities

    4 Order Relations

      4.1 Interface

      4.2 Utilities

    5 Functional Primitives

      5.1 Syntax

      5.2 Representation

      5.3 Utilities

      5.4 Types

        5.4.1 Interface

        5.4.2 Functions and Composition

        5.4.3 Function Application

    6 Composing Operations

      6.1 Interfaces

        6.1.1 Concatenation

        6.1.2 Multiplication

        6.1.3 Addition

      6.2 Types

      6.3 Utilities