git.fiddlerwoaroof.com
Browse code

Add new operator to make code clearer

fiddlerwoaroof authored on 02/12/2015 17:13:59
Showing 1 changed files
... ...
@@ -27,10 +27,11 @@ mvWAddStr2 w y x s = do
27 27
        in
28 28
        HSCurses.mvWAddStr w y x s2
29 29
 
30
+-- This is currently a stub
30 31
 dispatch :: HSCurses.Key -> IO ()
31 32
 dispatch _ = return ()
32 33
 
33
-(--->) :: Monad m => (a -> m b) -> (a -> m b) -> a -> m b
34
+(--->) :: Monad m => (a -> m b) -> (a -> m c) -> a -> m c
34 35
 (--->) = liftM2 (>>)
35 36
 
36 37
 passTo :: a -> (a -> b) -> b
... ...
@@ -42,7 +43,7 @@ mainLoop lim filein cols infinitep = stToIO (newSTRef 1) >>= loop
42 43
   where
43 44
     loop = discardResult . forever . wrapCode step HSCurses.refresh . stToIO . initialize
44 45
 
45
-    initialize n = readSTRef n >>= incSTRef n `keepOldBinding` addSTRefToTuple n
46
+    initialize n = readSTRef n >>= (incSTRef n ---> addSTRefToTuple n)
46 47
 
47 48
     step (x,nextX) = discardResult $ do
48 49
       let handleInputp = filein /= stdin && not infinitep && ( nextX `mod` lim == 0)
... ...
@@ -65,7 +66,6 @@ mainLoop lim filein cols infinitep = stToIO (newSTRef 1) >>= loop
65 66
     getLinePos = subtract 1 . (`mod` lim)
66 67
     handleInput handleInputp = when handleInputp $ HSCurses.getCh >>= dispatch
67 68
     incSTRef n = writeSTRef n . (+ 1)
68
-    keepOldBinding = liftM2 (>>)
69 69
     marker = "--- break ---"
70 70
     moveAndAddString = mvWAddStr2 HSCurses.stdScr
71 71
     wrapCode run finalize init = (init >>= run) >> finalize