@@ -6,6 +6,7 @@ module Effect.System
66import Effects
77import System
88import Control.IOExcept
9+import public Data.So
910
1011%access public export
1112
@@ -14,18 +15,21 @@ data System : Effect where
1415 Time : sig System Integer
1516 GetEnv : String -> sig System (Maybe String)
1617 CSystem : String -> sig System Int
18+ Usleep : (i : Int) -> (inbounds : So (i >= 0 && i <= 1000000)) -> sig System ()
1719
1820implementation Handler System IO where
1921 handle () Args k = do x <- getArgs; k x ()
2022 handle () Time k = do x <- time; k x ()
2123 handle () (GetEnv s) k = do x <- getEnv s; k x ()
2224 handle () (CSystem s) k = do x <- system s; k x ()
25+ handle () (Usleep i prf) k = do usleep i; k () ()
2326
2427implementation Handler System (IOExcept a) where
2528 handle () Args k = do x <- ioe_lift getArgs; k x ()
2629 handle () Time k = do x <- ioe_lift time; k x ()
2730 handle () (GetEnv s) k = do x <- ioe_lift $ getEnv s; k x ()
2831 handle () (CSystem s) k = do x <- ioe_lift $ system s; k x ()
32+ handle () (Usleep i prf) k = do ioe_lift $ usleep i; k () ()
2933
3034--- The Effect and associated functions
3135
@@ -43,3 +47,6 @@ getEnv s = call $ GetEnv s
4347
4448system : String -> Eff Int [SYSTEM]
4549system s = call $ CSystem s
50+
51+usleep : (i : Int) -> { auto prf : So (i >= 0 && i <= 1000000) } -> Eff () [SYSTEM]
52+usleep i {prf} = call $ Usleep i prf