• Stars
    star
    263
  • Rank 150,180 (Top 4 %)
  • Language
    Haskell
  • License
    BSD 2-Clause "Sim...
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Live recompiler for Haskell
โ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—     โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•”โ•โ•โ•
โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•  โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•โ•โ•  โ•šโ•โ•โ•โ•โ•โ•โ•

Live recompiler for Haskell

Halive Demo

Halive uses the GHC API to instantly recompile and reload your code any time you change it.

Usage: stack install halive

and then

halive <path/to/mymain.hs> <extra-include-dirs>

Any time you change a file in the current directory or its subdirectories, halive will recompile and rerun the main function in the file you gave it.

If the program is long-running (e.g. a daemon, GUI or game loop) it will be killed and restarted. Learn how to maintain state in the next section.

Try a live-coding GL demo by running:

# Grab the demo package and install the demo's dependencies - only need to do this once
stack unpack halive
cd halive-0.1.5
stack build --test --no-run-tests

# Now run Halive
halive demo/Main.hs

Changing values in Main.hs or Green.hs and saving should live-update the program.

Keeping values alive

To keep state alive, import Halive.Utils and wrap your value in reacquire along with a unique identifier, like:

win <- reacquire "win" (setupGLFW "HotGLFW" 640 480)

to only create the resource the first time you run the program, and then reuse it on subsequent recompilations.

You can see this in action in demo/Main.hs.

Thanks to Chris Done's foreign-store library for enabling this.

Watch custom file types for changes

By default, Halive will reload your code when files with the following extensions change: hs, pd, frag, vert.

If you have any other file type that you'd like to be watched by Halive, use the -f/--file-type option.

halive app/Main.hs -f html -f hamlet

Passing command-line arguments

To use Halive with haskell code that is expecting command-line arguments, separate the arguments to Halive and the arguments to the app with a -- such as:

halive <path/to/mymain.hs> <extra-include-dirs> -- <args-to-myapp>

Compiled Code

You can pass --compiled (or -c) to Halive to compile to faster object code.

This will be slower to recompile but faster to run.

Notes

Creating, updating, and deleting modules in the include path should work fine during a Halive session.

Halive supports Stack projects and Cabal sandboxes; if run within a directory containing a stack.yaml or cabal.sandbox.config file it will use the appropriate package databases when running the target.

Halive works nicely with either batch-processing or run-loop type programs โ€”ย if the program finishes, it will be restarted on next save, and if it's still running, it will be killed and restarted on save.

To kill Halive during run-loop type programs, you may need to hold down Ctrl-C to get GHC to recognize the double-Control-C-kill sequence.

Halive works on Windows, Mac, and Linux

As a Library

Halive can also be integrated into your own project as a library in a few lines of code. See test/TestSubHalive.hs for an example. IMPORTANT: You must link your binary with ghc-options: -dynamic for this to work! Otherwise you'll get mysterious linking errors on Mac and Linux.

Troubleshooting

If Halive with GLFW segfaults on windows, try git clone -b win-halive-fix http://github.com/lukexi/bindings-GLFW and adding the folder you cloned it to to your project's stack.yaml in the packages section

@lukexi

More Repositories

1

rumpus

A Livecoding Playground for Room-Scale VR
Pure Data
128
star
2

stack-ide-sublime

An Sublime Text IDE for Haskell based on stack-ide
Python
27
star
3

openvr-hs

Bindings for OpenVR and the Valve/HTC Vive
C++
10
star
4

pd-hs

Self-contained cross-platform Haskell bindings to LibPd and PortAudio
C
5
star
5

SublimeGHCi

A Sublime Text plugin to interactively interpret text in GHCi
Python
4
star
6

SceneKrift

DK2/SDK 0.4.1 implementation of rendering SceneKit scenes to the Rift
C
4
star
7

boxplorer2

Automatically exported from code.google.com/p/boxplorer2
C++
3
star
8

Hard

Micro-guard
Haskell
3
star
9

eglstreams-mini

Adapting EGLStreams to use NV_output_drm_flip_event
C
2
star
10

infinitybox

Multiplayer physics experiments
Pure Data
2
star
11

Undersong

2
star
12

NodeCanvasKit

A library for creating connectable node-graphs on iOS
Objective-C
1
star
13

SuperColliderPatternsInObjC

Objective-C
1
star
14

lua-dyco

C
1
star
15

strip-ths

Simple preprocessor for stripping Template Haskell splices
Haskell
1
star
16

DrawingKit

(super ancient) simple drawing helpers for prototyping core data/jsonkit/couchdb apps
Objective-C
1
star
17

futuretide-unity

C#
1
star
18

LXKit

(super ancient) old grab bag utils for objc
Objective-C
1
star
19

ghc-7.8-arm64

A backport of my ARM64 patches for GHC to GHC 7.8
Haskell
1
star
20

CoreCouchKit

(super ancient) experiments with syncing core data with couchdb
Objective-C
1
star
21

scripts

Perl
1
star
22

oculus-mini

Minimal Haskell bindings to Oculus Rift SDK, with GL/GLFW example
C++
1
star
23

futuretide

C#
1
star
24

HelloChair4

(super ancient) collaborative drawing/remixing app
Objective-C
1
star
25

CoreDataJSONKit

(super ancient) experiment in turning any Core Data graph into JSON and back again
Objective-C
1
star
26

dyco

C
1
star
27

reshader

A shader loader and live shader recompiler for the gl package
Haskell
1
star
28

Pulsar

A free-routable synthesis node structure library for SuperCollider and iOS
Objective-C
1
star
29

wboit

Weighted Blended Order-Independent Transparency in Haskell/gl
Haskell
1
star