essence-of-live-coding-0.2.6: General purpose live coding framework
Safe HaskellNone
LanguageHaskell2010

LiveCoding.RuntimeIO.Launch

Synopsis

Documentation

class Monad m => Launchable m where Source #

Monads in which live programs can be launched in IO, for example when you have special effects that have to be handled on every reload.

The only thing necessary is to transform the LiveProgram into one in the IO monad, and the rest is taken care of in the framework.

Instances

Instances details
Launchable IO Source # 
Instance details

Defined in LiveCoding.RuntimeIO.Launch

(Typeable m, Launchable m) => Launchable (HandlingStateT m) Source # 
Instance details

Defined in LiveCoding.RuntimeIO.Launch

(Data e, Finite e, Launchable m) => Launchable (ExceptT e m) Source #

Upon an exception, the program is restarted. To handle or log the exception, see LiveCoding.LiveProgram.Except.

Instance details

Defined in LiveCoding.RuntimeIO.Launch

liveMain :: Launchable m => LiveProgram m -> IO () Source #

The standard top level main for a live program.

Typically, you will define a top level LiveProgram in some monad like HandlingStateT IO, and then add these two lines of boiler plate:

main :: IO ()
main = liveMain liveProgram

foreground :: Monad m => LiveProgram m -> m () Source #

Launch a LiveProgram in the foreground thread (blocking).

data LaunchedProgram (m :: * -> *) Source #

A launched LiveProgram and the thread in which it is running.

launch :: Launchable m => LiveProgram m -> IO (LaunchedProgram m) Source #

Launch a LiveProgram in a separate thread.

The MVar can be used to update the program while automatically migrating it. The ThreadId represents the thread where the program runs in. You're advised not to kill it directly, but to run stop instead.

update :: Launchable m => LaunchedProgram m -> LiveProgram m -> IO () Source #

Migrate (using hotCodeSwap) the LiveProgram to a new version.

stop :: Launchable m => LaunchedProgram m -> IO () Source #

Stops a thread where a LiveProgram is being executed.

Before the thread is killed, an empty program (in the monad m) is first inserted and stepped. This can be used to call cleanup actions encoded in the monad, such as HandlingStateT.

launchWithDebugger :: (Monad m, Launchable m) => LiveProgram m -> Debugger m -> IO (LaunchedProgram m) Source #

Launch a LiveProgram, but first attach a debugger to it.

background :: MVar (LiveProgram IO) -> IO () Source #

This is the background task executed by launch.

stepProgram :: Monad m => LiveProgram m -> m (LiveProgram m) Source #

Advance a LiveProgram by a single step.

stepLaunchedProgram :: (Monad m, Launchable m) => LaunchedProgram m -> IO () Source #

Advance a launched LiveProgram by a single step and store the result.