@@ -0,0 +1,38 @@
3+-- Various system interaction features (this is not necessarily the right way
4+-- to split them up, I just need some of them now :))
8+import Control.IOExcept
10+data System : Effect where
11+ Args : { () } System (List String)
12+ Time : { () } System Int
13+ GetEnv : String -> { () } System (Maybe String)
15+instance Handler System IO where
16+ handle () Args k = do x <- getArgs; k x ()
17+ handle () Time k = do x <- time; k x ()
18+ handle () (GetEnv s) k = do x <- getEnv s; k x ()
20+instance Handler System (IOExcept a) where
21+ handle () Args k = do x <- ioe_lift getArgs; k x ()
22+ handle () Time k = do x <- ioe_lift time; k x ()
23+ handle () (GetEnv s) k = do x <- ioe_lift $ getEnv s; k x ()
25+--- The Effect and associated functions
28+SYSTEM = MkEff () System
30+getArgs : Handler System e => { [SYSTEM] } Eff e (List String)
33+time : Handler System e => { [SYSTEM] } Eff e Int
36+getEnv : Handler System e => String -> { [SYSTEM] } Eff e (Maybe String)