on master help sign in
Merge pull request #1336 from Heather/system

add system to Effects.System as is

commit9183cd711c34bcad5db264e153c2a42a335a1d6b authorEdwin Brady <edwin.brady@gmail.com> dateTue 1 Jul 2014, 11:40 (12 years ago) parentf60626fded4d17
2 files changed+10
libs/effects/Effect/System.idr+5 libs/neweffects/Effect/System.idr+5
libs/effects/Effect/System.idr+5
@@ -11,16 +11,19 @@ data System : Effect where
1111 Args : { () } System (List String)
1212 Time : { () } System Int
1313 GetEnv : String -> { () } System (Maybe String)
14+ CSystem : String -> { () } System Int
1415
1516instance Handler System IO where
1617 handle () Args k = do x <- getArgs; k x ()
1718 handle () Time k = do x <- time; k x ()
1819 handle () (GetEnv s) k = do x <- getEnv s; k x ()
20+ handle () (CSystem s) k = do x <- system s; k x ()
1921
2022instance Handler System (IOExcept a) where
2123 handle () Args k = do x <- ioe_lift getArgs; k x ()
2224 handle () Time k = do x <- ioe_lift time; k x ()
2325 handle () (GetEnv s) k = do x <- ioe_lift $ getEnv s; k x ()
26+ handle () (CSystem s) k = do x <- ioe_lift $ system s; k x ()
2427
2528--- The Effect and associated functions
2629
@@ -36,3 +39,5 @@ time = call Time
3639getEnv : Handler System e => String -> { [SYSTEM] } Eff e (Maybe String)
3740getEnv s = call $ GetEnv s
3841
42+system : Handler System e => String -> { [SYSTEM] } Eff e Int
43+system s = call $ CSystem s
libs/neweffects/Effect/System.idr+5
@@ -11,16 +11,19 @@ data System : Effect where
1111 Args : { () } System (List String)
1212 Time : { () } System Int
1313 GetEnv : String -> { () } System (Maybe String)
14+ CSystem : String -> { () } System Int
1415
1516instance Handler System IO where
1617 handle () Args k = do x <- getArgs; k x ()
1718 handle () Time k = do x <- time; k x ()
1819 handle () (GetEnv s) k = do x <- getEnv s; k x ()
20+ handle () (CSystem s) k = do x <- system s; k x ()
1921
2022instance Handler System (IOExcept a) where
2123 handle () Args k = do x <- ioe_lift getArgs; k x ()
2224 handle () Time k = do x <- ioe_lift time; k x ()
2325 handle () (GetEnv s) k = do x <- ioe_lift $ getEnv s; k x ()
26+ handle () (CSystem s) k = do x <- ioe_lift $ system s; k x ()
2427
2528--- The Effect and associated functions
2629
@@ -36,3 +39,5 @@ time = call Time
3639getEnv : String -> { [SYSTEM] } Eff (Maybe String)
3740getEnv s = call $ GetEnv s
3841
42+system : String -> { [SYSTEM] } Eff Int
43+system s = call $ CSystem s