disco: Functional programming language for teaching discrete math.

[ bsd3, language, library, program ] [ Propose Tags ]
Versions [RSS],,,,, 0.1.4, 0.1.5, 0.1.6
Change log CHANGELOG.md
Dependencies algebraic-graphs (>=0.5 && <0.8), arithmoi (>=0.10 && <0.14), base (>=4.8 && <4.18), containers (>=0.5 && <0.7), directory, disco, exact-combinatorics (>=0.2 && <0.3), exceptions (>=0.10 && <0.11), fgl (>=5.5 && <5.9), filepath, haskeline (>=0.8 && <0.9), integer-logarithms (>=1.0 && <1.1), lens (>=4.14 && <5.3), megaparsec (>=6.1.1 && <9.6), mtl (>=2.2 && <2.4), optparse-applicative (>=0.12 && <0.19), parser-combinators (>=1.0.0 && <1.4), polysemy (>= && <1.10), polysemy-plugin (>=0.4 && <0.5), polysemy-zoo (>=0.7 && <0.9), pretty-show (>=1.10 && <1.11), prettyprinter (>=1.7 && <1.8), QuickCheck (>=2.9 && <2.15), simple-enumeration (>=0.2 && <0.3), split (>=0.2 && <0.3), splitmix (>=0.1 && <0.2), transformers (>=0.4 && <0.7), unbound-generics (>=0.3 && <0.4.3) [details]
License BSD-3-Clause
Copyright Disco team 2016-2022 (see LICENSE)
Author Disco team
Maintainer byorgey@gmail.com
Category Language
Source repo head: git clone git://github.com/disco-lang/disco.git
Uploaded by BrentYorgey at 2023-12-16T20:14:48Z
Executables disco
Downloads 519 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
All reported builds failed as of 2023-12-16 [all 1 reports]

Readme for disco-0.1.6

[back to package description]

Build Status Contributor Covenant

Disco is a programming language intended to teach basic functional programming principles in the context of a discrete mathematics course.

Using Disco on replit.com

If you just want to use disco (i.e. if you are a student, or just checking out the language), the recommended way is to use it via replit.com. Simply visit this REPL and follow the instructions there to fork your own copy, where you will be able to evaluate Disco expressions, and edit and run your own .disco files, all via your web browser, without installing anything on your computer.

Design principles

  • Includes those features, and only those features, useful in the context of a discrete math course. This is not intended to be a general-purpose language.
  • Syntax is as close to standard mathematical practice as possible, to make it easier for mathematicians to pick up, and to reduce as much as possible the incongruity between the language and the mathematics being explored and modeled.
  • Tooling, error messages, etc. are very important---the language needs to be accessible to undergrads with no prior programming experience. (However, this principle is, as of yet, only that---there is no tooling or nice error messages to speak of.)

Feel free to look around, ask questions, etc. You can also contribute---collaborators are most welcome.


Check out the disco IRC channel, #disco-lang on Libera.Chat. If you're not familiar with IRC, you can connect via this web client.


Documentation is hosted on readthedocs.io.


If you'd like to contribute to disco development, check out CONTRIBUTING.md.

Building with stack

First, make sure you have the stack tool (the easiest way to install it is via ghcup). Then open a command prompt, navigate to the root directory of this repository, and execute

stack build

After this completes, you should be able to

stack exec disco

to run the Disco command-line REPL.

While developing, you may want to use a command like

stack test --fast --file-watch --ghc-options='-Wall'

which will turn on warnings, turn off optimizations for a faster edit-compile-test cycle, and automatically recompile and run the test suite every time a source file changes.


If for some reasons you want to actually install disco on your computer, follow the below instructions. (If you want to contribute to disco development, you should skip to the instructions about building with stack.)

Note, if you are a student, you should not need to do this! The above instructions about using disco on replit.com should be all you need. The below instructions are kept here for completeness.

  • Follow the instructions to install ghcup by opening a terminal or command prompt and copy-pasting the given installation command. You can just accept all the defaults. If you don't have Windows Subsystem for Linux (if you don't know what that is, then you don't have it), see the instructions here for a PowerShell command to run.

    • If you use PowerShell, note that after running the magic PowerShell command to set up ghcup, you need to close and reopen PowerShell in order for it to recognize the cabal command.
  • Run cabal update, which will download the latest information about Haskell packages.

  • Now run cabal install disco at a command prompt.

    • Note that this may take a very long time, on the order of an hour or so.

    • The good news is that most of this work only needs to be done once, even if you later install an updated version of disco. Even if installation fails partway through, the work already completed up to that point need not be redone.

    • On OSX, if building fails with an error like ghc: could not execute: opt, it means you need to install LLVM. The easiest way to do this is to first follow the instructions to install Homebrew (if you don't already have it), and then type

      brew install llvm

      at a terminal prompt.

      • If this fails with an error like Could not resolve HEAD to a revision, then try running these two commands at a terminal prompt:

        rm -rf $(brew --repo homebrew/core)
        brew tap homebrew/core

        Then re-run the brew install llvm command.

      • After installing llvm, you may need to close and re-open the terminal before running cabal install disco again.

  • If it works, you should be able to now type disco at a command prompt, which should display a message like this:

    Welcome to Disco!
    A language for programming discrete mathematics.
  • If installation seems like it succeeded but the disco command is not recognized, it may be an issue with your path environment variable settings. Try running disco using an explicit path:

    • ~/.cabal/bin/disco on Linux or OSX
    • C:\cabal\bin\disco on Windows
    • If those don't work, poke around and see if you can figure out where the cabal/bin folder is on your computer, and run disco from there.
    • If you wish, you may add the cabal/bin folder (wherever it is located) to your Path (Windows) or PATH (Linux/OSX) environment variable, so that you can run disco simply by typing disco. However, this step is optional.
  • On Windows, if disco crashes with an error about foldr after you try to type anything (or if it simply closes the entire window when you type anything), the problem is probably that you need to enable UTF-8 mode.

    • Open a command prompt, and type

      chcp 65001
    • Now start disco as before (by typing disco or C:\cabal\bin\disco or whatever worked).

    • You will have to do this every time you run disco. Alternatively, you can create a file called disco.cmd containing those two commands, for example:

      chcp 65001

      Now you can simply double-click on disco.cmd to run disco.

If you encounter any difficulties, please let me know --- either come talk to me or open a GitHub issue. These instructions will be kept up-to-date with whatever helpful tips or workarounds I learn. So even if you encounter a difficulty but figure out the solution youself, let me know --- that way I can include the problem and solution here so others can benefit!