aboutsummaryrefslogtreecommitdiff
path: root/ch15/SafeHello.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ch15/SafeHello.hs')
-rw-r--r--ch15/SafeHello.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/ch15/SafeHello.hs b/ch15/SafeHello.hs
new file mode 100644
index 0000000..91a7ff1
--- /dev/null
+++ b/ch15/SafeHello.hs
@@ -0,0 +1,12 @@
+module SafeHello where
+
+import MonadHandle
+import System.IO (IOMode(..))
+
+{-- snippet safeHello --}
+safeHello :: MonadHandle h m => FilePath -> m ()
+safeHello path = do
+ h <- openFile path WriteMode
+ hPutStrLn h "hello world"
+ hClose h
+{-- /snippet safeHello --}