aboutsummaryrefslogtreecommitdiff
path: root/ch15/SafeHello.hs
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-07-30 10:29:40 +0200
committerJan Sucan <jan@jansucan.com>2025-07-30 10:29:40 +0200
commitb801218e7627f98556ab7d1acbefbbf8daafd851 (patch)
tree16d4aa53f26cad069514de1352baadf687ee28b2 /ch15/SafeHello.hs
parent8463154bfa3112ba328d3645ff7fe25b25c433ae (diff)
15_a_1 and 15_a_2: Add solutions
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 --}