Skip to content

turion/essence-of-live-coding-tutorial

Repository files navigation

Tutorial for essence-of-live-coding

About the library

essence-of-live-coding is a general purpose and type safe live coding framework in Haskell. You can run programs in it, and edit, recompile and reload them while they're running. Internally, the state of the live program is automatically migrated when performing hot code swap.

The library also offers an easy to use FRP interface. It is parametrized by its side effects, separates data flow cleanly from control flow, and allows to develop live programs from reusable, modular components. There are also useful utilities for debugging and quickchecking.

Learn more here

Installation

  1. Clone this repository and enter it:
    git clone https://github.com/turion/essence-of-live-coding-tutorial
    cd essence-of-live-coding-tutorial
    
  2. Either install nix and launch a nix-shell, or install the external dependencies listed below
  3. cabal update (A new version of the library was released recently)
  4. Sanity check: Launch cabal repl and close it again. This should succeed without errors.
  5. Open Main.hs in an editor.
  6. Run ghcid from the console.

You should now be seeing a window containing a solid circle (a ball). If you click anywhere in the window, the ball will start to move in that direction. Once you make changes to Main.hs, it will automatically reload.

External dependencies

  • Ideally, a Linux system. (See below.)
  • A standard Haskell development environment, including cabal and ghci. (stack is not needed.) Supported GHC versions are 8.6 and 8.8.
  • ghcid.
  • OpenGL development libraries and PulseAudio development libraries. (For other sound setups, see below.) In Debian-based systems, this amounts to installing these packages: libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libpulse-dev libblas-dev liblapack-dev

Nix cache & nixpkgs versions

  • The nix-shell is pinned to an up-to-date version of nixos-unstable. This may cause a long build. You can alleviate that by using cachix, or using a different nixpkgs version.
  • If you use cachix, you can speed up your build by using cachix use manuelbaerenz. I'm uploading build artifacts there.
  • To use a different nixpkgs, edit the first lines of mypkgs.nix, and re-run nix-shell.

Non-Linux systems

Windows

I cannot give Windows support for graphics, since I don't have a Windows machine. If you have a Windows machine, you'd like to get graphics to run on your machine, and you're willing to test a backend and setup with me, please contact me via a Github issue.

macOS

Graphics/OpenGL support on macOS seems to be broken, see #3. If you know how to fix such an issue, please comment, and we'll resolve it so you can use graphics on macOS.

Sound support

Currently, I only have audio support ready for Linux, PulseAudio, since this is the platform on which I develop. If you have a different system, we will still be able to get sound working if you know of good Haskell bindings to your sound system. If that is the case, please open an issue on https://github.com/turion/essence-of-live-coding/issues so we can prepare a sound backend before the tutorial.

Either way, the tutorial will focus mainly on video, and only add further backends as time permits.

Helpful resources during the tutorial

Tasks during the tutorial

Task Branch
Magnet (Ball stops when it is very slow) progress1_magnet
Goal hole with high friction progress2_goal
Obstacle type progress3_obstacle_type
Draw obstacles, simulate repulsion progress4_obstacles
Connect warp backend, print last query progress5_connect_warp
Parse warp impulse query progress6_warp_impulse
Stretch goal: Add sound solution_pulse

About

Tutorial for essence-of-live-coding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published