on master help sign in
Fixed bitrot from change to new Effects API.

During the recent inclusion of the new Effects API, recent changes made to the established version were not propagated to the new version.

commitac5ca2a149f5e7f99b7ea60d7ea3c5315d0ec193 authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateTue 14 Apr 2015, 23:20 (12 years ago) parentb450502
2 files changed+21−10
libs/effects/Effect/Exception.idr+3−3 libs/effects/Effect/StdIO.idr+18−7
libs/effects/Effect/Exception.idr+3−3
@@ -4,7 +4,7 @@ import Effects
44import System
55import Control.IOExcept
66
7−data Exception : Type -> Effect where
7+data Exception : Type -> Effect where
88 Raise : a -> sig (Exception a) b
99
1010instance Handler (Exception a) Maybe where
@@ -14,7 +14,7 @@ instance Handler (Exception a) List where
1414 handle _ (Raise e) k = []
1515
1616instance Show a => Handler (Exception a) IO where
17− handle _ (Raise e) k = do print e
17+ handle _ (Raise e) k = do printLn e
1818 believe_me (exit 1)
1919
2020instance Handler (Exception a) (IOExcept a) where
@@ -26,5 +26,5 @@ instance Handler (Exception a) (Either a) where
2626EXCEPTION : Type -> EFFECT
2727EXCEPTION t = MkEff () (Exception t)
2828
29−raise : a -> Eff b [EXCEPTION a]
29+raise : a -> Eff b [EXCEPTION a]
3030raise err = call $ Raise err
libs/effects/Effect/StdIO.idr+18−7
@@ -9,8 +9,8 @@ import Control.IOExcept
99
1010||| The internal representation of StdIO effects
1111data StdIO : Effect where
12− PutStr : String -> sig StdIO ()
13− GetStr : sig StdIO String
12+ PutStr : String -> sig StdIO ()
13+ GetStr : sig StdIO String
1414 PutCh : Char -> sig StdIO ()
1515 GetCh : sig StdIO Char
1616
@@ -22,13 +22,13 @@ data StdIO : Effect where
2222instance Handler StdIO IO where
2323 handle () (PutStr s) k = do putStr s; k () ()
2424 handle () GetStr k = do x <- getLine; k x ()
25− handle () (PutCh c) k = do putChar c; k () ()
25+ handle () (PutCh c) k = do putChar c; k () ()
2626 handle () GetCh k = do x <- getChar; k x ()
2727
2828instance Handler StdIO (IOExcept a) where
2929 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
3030 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
31− handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
31+ handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
3232 handle () GetCh k = do x <- ioe_lift $ getChar; k x ()
3333
3434-------------------------------------------------------------
@@ -42,13 +42,17 @@ STDIO = MkEff () StdIO
4242putStr : String -> Eff () [STDIO]
4343putStr s = call $ PutStr s
4444
45+||| Write a string to standard output, terminating with a newline.
46+putStrLn : String -> Eff () [STDIO]
47+putStrLn s = putStr (s ++ "\n")
48+
4549||| Write a character to standard output.
4650putChar : Char -> Eff () [STDIO]
4751putChar c = call $ PutCh c
4852
49−||| Write a string to standard output, terminating with a newline.
50−putStrLn : String -> Eff () [STDIO]
51−putStrLn s = putStr (s ++ "\n")
53+||| Write a character to standard output, terminating with a newline.
54+putCharLn : Char -> Eff () [STDIO]
55+putCharLn c = putStrLn (singleton c)
5256
5357||| Read a string from standard input.
5458getStr : Eff String [STDIO]
@@ -58,3 +62,10 @@ getStr = call $ GetStr
5862getChar : Eff Char [STDIO]
5963getChar = call $ GetCh
6064
65+||| Given a parameter `a` 'show' `a` to standard output.
66+print : Show a => a -> Eff () [STDIO]
67+print a = putStr (show a)
68+
69+||| Given a parameter `a` 'show' `a` to a standard output, terminating with a newline
70+printLn : Show a => a -> Eff () [STDIO]
71+printLn a = putStrLn (show a)