git @ Cat's Eye Technologies Robin / fbc9544
Sketch init and produceEvents for LineTerminal facility. Chris Pressey 5 years ago
2 changed file(s) with 22 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
44
55 import Language.Robin.Expr
66 import Language.Robin.Facilities
7
8
9 import Control.Concurrent (forkIO, myThreadId)
10 import Control.Concurrent.Chan
11
12
13 -- sketch
14 init :: IO FacilityHandler
15 init = do
16 chan <- newChan
17 threadId <- forkIO $ produceEvents chan
18 return handleEvent
19
20
21 -- sketch
22 produceEvents :: Chan Event -> IO ()
23 produceEvents chan = do
24 event <- waitForEvent
25 writeChan chan event
26 produceEvents chan
727
828
929 waitForEvent :: WaitForEvents
11
22 import Language.Robin.Expr
33
4 type Event = Either String [Expr]
45 type FacilityHandler = Expr -> IO [Expr]
5 type WaitForEvents = IO (Either String [Expr])
6 type WaitForEvents = IO Event