On this page:
Qi:   A Functional, Flow-Oriented DSL
8.6

Qi: A Functional, Flow-Oriented DSL

 (require qi) package: qi-lib

An embeddable, general-purpose language to allow convenient framing of programming logic in terms of functional flows.

Start by getting your bearings. For an overview of the language, continue to Introduction and Usage. For a thorough orientation, watch the original video from RacketCon 2021.

    1 Using These Docs

    2 Introduction and Usage

      2.1 Overview

      2.2 Installation

      2.3 Usage

      2.4 Flowing with the Flow

        2.4.1 DrRacket

        2.4.2 Vim/Emacs

          2.4.2.1 Keybindings

          2.4.2.2 Indentation

      2.5 Relationship to the Threading Macro

    3 Tutorial

      3.1 Interactive Tutorial

        3.1.1 Installation

        3.1.2 Setup

          3.1.2.1 DrRacket

          3.1.2.2 Emacs

          3.1.2.3 Vim

      3.2 Online Tutorial

    4 Language Interface

      4.1 Using Qi from the Host Language

        4.1.1 Core

        4.1.2 Threading

        4.1.3 Conditionals

        4.1.4 Lambdas

        4.1.5 Definitions

      4.2 Using the Host Language from Qi

        4.2.1 Using Racket Values in Qi Flows

        4.2.2 Using Racket to Define Flows

        4.2.3 Using Racket Macros as Flows

      4.3 Using Qi with Another DSL

        4.3.1 Using Qi Directly

        4.3.2 Using a Macro Bridge

        4.3.3 Writing a Qi Dialect

    5 The Qi Language

      5.1 Basic

      5.2 Predicates

      5.3 Boolean Algebra

      5.4 Routing

      5.5 Conditionals

      5.6 Loops

      5.7 Exceptions

      5.8 Higher-order Flows

      5.9 Identifiers

      5.10 Literals

      5.11 Templates and Partial Application

      5.12 Utilities

      5.13 Language Extension

    6 Qi Macros

      6.1 Defining Macros

      6.2 Using Macros

        6.2.1 Racket Version Compatibility

      6.3 Adding New Language Features

        6.3.1 Write Yourself a Maybe Monad for Great Good

        6.3.2 Translating Foreign Macros

      6.4 Writing Languages in Qi

        6.4.1 Embedded Languages

        6.4.2 Hosted Languages

        6.4.3 Embedding a Hosted Language

          6.4.3.1 Exercise: Pattern Matching

    7 Field Guide

      7.1 Writing Flows

        7.1.1 Start by Drawing a Circuit Diagram

        7.1.2 Use Small Building Blocks

        7.1.3 Carry Your Toolbox

      7.2 Debugging

        7.2.1 Using Side Effects

        7.2.2 Using a Probe

        7.2.3 Using Fixtures

        7.2.4 Common Errors and What They Mean

          7.2.4.1 Expected Number of Values Not Received

          7.2.4.2 Wildcard Not Allowed as an Expression

          7.2.4.3 Bad Syntax

          7.2.4.4 Use Does Not Match Pattern

          7.2.4.5 Expected Identifier Not Starting With Character

          7.2.4.6 Not Defined as Syntax Class

          7.2.4.7 Too Many Ellipses in Template

          7.2.4.8 Syntax: Unbound Identifier

          7.2.4.9 Undefined

          7.2.4.10 Compose: Contract Violation

          7.2.4.11 List Arity Mismatch

          7.2.4.12 Fancy-app Arity Mismatch

        7.2.5 Gotchas

          7.2.5.1 null is Not a Literal

          7.2.5.2 There’s No Escaping esc

          7.2.5.3 Mutable Values Defy the Laws of Flows

      7.3 Effectively Using Feedback Loops

        7.3.1 Control Values and Data Values

        7.3.2 Input Tracing

        7.3.3 Keeping It Tidy

      7.4 Idioms and Transforms

        7.4.1 Nested Applications are Sequential Flows

        7.4.2 Converting a Function to a Closure

        7.4.3 Converting a Macro to a Flow

        7.4.4 Bindings are an Alternative to Nonlinearity

    8 Principles of Qi

      8.1 What is a Flow?

      8.2 Values, Paths and Flows

      8.3 Values are Not Collections

      8.4 Everything is a Function

      8.5 Flowy Logic

      8.6 Phrases

      8.7 Identities

      8.8 Flows and Arrows

    9 When Should I Use Qi?

      9.1 Hadouken!

        9.1.1 Super Smush Numbers

        9.1.2 Root-Mean-Square

      9.2 The Science of Deduction

        9.2.1 Compound Predicates

        9.2.2 abs

        9.2.3 Range

        9.2.4 Length

      9.3 Curbing Curries and Losing Lambdas

      9.4 Making the Switch

      9.5 The Structure and Interpretation of Flows

      9.6 Using the Right Tool for the Job