19 lines
505 B
Plaintext
19 lines
505 B
Plaintext
!import "base" !Local
|
|
!import "list" !Local
|
|
!import "io" !Local
|
|
|
|
-- Basic fork and await.
|
|
-- fork spawns a concurrent task and returns a handle.
|
|
-- await blocks until the task completes and returns its value.
|
|
|
|
worker = msg :
|
|
bind (putStrLn (append "working: " msg)) (_ :
|
|
pure (append msg "-result"))
|
|
|
|
main = io <|
|
|
(bind (fork (worker "job1")) (h1 :
|
|
bind (fork (worker "job2")) (h2 :
|
|
bind (await h1) (r1 :
|
|
bind (await h2) (r2 :
|
|
putStrLn (append "Got " (append r1 (append " and " r2))))))))
|