Skip to content

Commit 9448549

Browse files
committed
before leaving jp
1 parent b10871b commit 9448549

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

MonadExample/gcd.hs

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ output = mapM_ putStrLn . fromDiffList. snd . runWriter . finalCountDown
4040

4141
output2 :: Int -> IO ()
4242
output2 = mapM_ putStrLn . snd . runWriter . finalCountDown'
43+

MonadExample/stack.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import Control.Monad.State
33
type Stack = [Int]
44

55
pop :: State Stack Int
6-
pop = State $ \(x:xs) -> (x,xs)
6+
pop = state $ \(x:xs) -> (x,xs)
77

88
push :: Int -> State Stack ()
9-
push a = State $ \xs -> ((), a:xs)
9+
push a = state $ \xs -> ((), a:xs)
1010

1111
stackMainip :: State Stack Int
1212
stackMainip = do
1313
push 3
14-
pop
14+
push 4
15+
push 5
1516
pop

0 commit comments

Comments
 (0)