mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-29 22:51:51 +03:00
24 lines
395 B
Idris
24 lines
395 B
Idris
|
module Futures
|
||
|
|
||
|
import Data.List
|
||
|
import Data.So
|
||
|
import System
|
||
|
import System.Future
|
||
|
import System.Info
|
||
|
|
||
|
constant : IO ()
|
||
|
constant = do
|
||
|
let a = await $ fork "String"
|
||
|
putStrLn a
|
||
|
|
||
|
map : IO ()
|
||
|
map = do
|
||
|
future1 <- forkIO $ do
|
||
|
usleep 10000
|
||
|
putStrLn "#2"
|
||
|
let future3 = map (const "#3") future1
|
||
|
future2 <- forkIO $ do
|
||
|
putStrLn "#1"
|
||
|
pure $ await future2
|
||
|
putStrLn (await future3)
|