Move Set 11b Ex 5 to Set 13b

This commit is contained in:
Joel Kaasinen
2021-06-19 22:11:02 +03:00
parent 5e294d47c1
commit 580b512db0
4 changed files with 41 additions and 39 deletions
-28
View File
@@ -82,34 +82,6 @@ doubleCall op = todo
compose :: (a -> IO b) -> (c -> IO a) -> c -> IO b
compose op1 op2 c = todo
------------------------------------------------------------------------------
-- Ex 5: Implement the operation mkCounter that produces the IO operations
-- inc :: IO () and get :: IO Int. These operations should work like this:
--
-- get returns the number of times inc has been called
--
-- In other words, a simple stateful counter. Use an IORef to store the count.
--
-- Note: this is an IO operation that produces two IO operations. Thus
-- the type of mkCounter is IO (IO (), IO Int).
--
-- This exercise is tricky. Feel free to leave it until later.
--
-- An example of how mkCounter works in GHCi:
--
-- *Set11b> (inc,get) <- mkCounter
-- *Set11b> inc
-- *Set11b> inc
-- *Set11b> get
-- 2
-- *Set11b> inc
-- *Set11b> inc
-- *Set11b> get
-- 4
mkCounter :: IO (IO (), IO Int)
mkCounter = todo
------------------------------------------------------------------------------
-- Ex 6: Reading lines from a file. The module System.IO defines
-- operations for Handles, which represent open files that can be read