Poop (pstron)

From Esolang
Jump to navigation Jump to search

Poop is a functional esoteric programming language created by pstron, where everything is a poop and computation happens by pooping into other poops. It is based on lambda calculus with a minimal syntax centered around toilet humor metaphors. The language is implemented as an interpreter written in Haskell.

Overview

Poop has no assignments, no mutable objects, and no traditional control structures. Instead, programs are built from three core primitives: poop (lambda abstraction), pooping (function application), and macro definitions. Execution proceeds via substitution, expanding macros and replacing parameters until a result is produced.

Syntax

Tokens and Whitespace

Tokens must be separated by whitespace (spaces, tabs, or newlines).

Comments

  • Single‐line: // comment
  • Multi‐line: /* comment */

Identifiers

  • Variable names: lowercase letters and underscores ([a-z_]+).
  • Macro names: any identifier that is not a valid variable name; commonly written in PascalCase. May include digits and symbols.

Literals

Literals are enclosed between Po and op. The content between them is taken literally.

  • Poop → a single space.
  • Popoopop → the string "poop" (used to avoid keyword interpretation).

Literals are never expanded as macros or treated as keywords.

Primitives

poop (abstraction)

poop ⟨param⟩ poops ⟨body⟩ qooq

Creates a lambda abstraction. When applied, every occurrence of ⟨param⟩ in ⟨body⟩ is replaced with the argument.

pooping (application)

pooping ⟨expr₁⟩ poopy ⟨expr₂⟩ qooq

Applies ⟨expr₂⟩ to ⟨expr₁⟩. Evaluation is strict (applicative order).

Macro definition

poop ⟨name⟩ is ⟨content⟩ qooq

Defines ⟨name⟩ as a macro that expands to ⟨content⟩. Macros are non‑recursive and are expanded during execution.

Built‑in macros

Input

When encountered, the interpreter pauses and reads one line from the user. The line is parsed as Poop code and replaces the Input macro in the program. This allows the user to supply both data and code dynamically.

Print

pooping Print poopy ⟨x⟩ qooq

Evaluates ⟨x⟩, prints its string representation to standard output, and returns ⟨x⟩ unchanged (i.e., it behaves as the identity function with a side effect).

Examples

Hello World

// Define a greeting macro
poop Greet is
  poop name poops
    Hello Poop name
  qooq
qooq

// Print "Hello World"
pooping Print poopy
  pooping Greet poopy World qooq
qooq

Church numerals

// Church numeral zero
poop 0 is
  poop f poops poop x poops x qooq qooq
qooq

// Successor function
poop Succ is
  poop n poops
    poop f poops
      poop x poops
        pooping f poopy
          pooping pooping n poopy f qooq poopy x qooq
        qooq
      qooq
    qooq
  qooq
qooq

Computational class

Poop is Turing complete because it implements the untyped lambda calculus with macro expansion (which provides a form of recursion/composition). Church numerals and fixed‑point combinators can be expressed.

Implementation

The reference implementation is written in Haskell and available on GitHub: pstron/poop. The project is dual‑licensed under the MIT License and a custom "Poop License" that disclaims all liability.

See also

External resources