haste-compiler-0.2.99: Haskell To ECMAScript compiler

Safe HaskellNone

Haste.Concurrent

Description

Concurrency for Haste. Includes MVars, forking, Ajax and more.

Synopsis

Documentation

wait :: Int -> CIO ()Source

Wait for n milliseconds.

server :: state -> (state -> evt -> CIO (Maybe state)) -> CIO (MVar evt)Source

Creates a generic server thread. A server is a function taking a state and an event argument, returning an updated state or Nothing. server creates an MVar that is used to pass events to the server. Whenever a value is written to this MVar, that value is passed to the server function togeter with its current state. If the server function returns Nothing, the server thread terminates. If it returns a new state, the server again blocks on the event MVar, and will use the new state to any future calls to the server function.