essence-of-live-coding
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.
git clone https://github.com/turion/essence-of-live-coding-tutorial
cd essence-of-live-coding-tutorial
nix
and launch a nix-shell
,
or install the external dependencies listed belowcabal update
(A new version of the library was released recently)cabal repl
and close it again.
This should succeed without errors.Main.hs
in an editor.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.
cabal
and ghci
.
(stack
is not needed.)
Supported GHC versions are 8.6 and 8.8.ghcid
.libgl1-mesa-dev
libglu1-mesa-dev
freeglut3-dev
libpulse-dev
libblas-dev
liblapack-dev
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.cachix
,
you can speed up your build by using cachix use manuelbaerenz
.
I'm uploading build artifacts there.nixpkgs
, edit the first lines of mypkgs.nix
, and re-run nix-shell
.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.
Graphics/OpenGL support on macOS seems to be broken, see https://github.com/turion/essence-of-live-coding-tutorial/issues/3. If you know how to fix such an issue, please comment, and we'll resolve it so you can use graphics on macOS.
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.
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 |