Selaa lähdekoodia

Improve IO in Lib

main
Jens Kadenbach 2 vuotta sitten
vanhempi
commit
e50555fe8b
3 muutettua tiedostoa jossa 10 lisäystä ja 20 poistoa
  1. 1
    1
      src/Day5/Shared.hs
  2. 1
    1
      src/Day7/Parser.hs
  3. 8
    18
      src/Lib.hs

+ 1
- 1
src/Day5/Shared.hs Näytä tiedosto

@@ -30,7 +30,7 @@ data Operation = Operation
30 30
 type Content = Char
31 31
 newtype Stack = Stack [Content] deriving (Show, Eq)
32 32
 
33
-content :: Stack  -> [Content]
33
+content :: Stack -> [Content]
34 34
 content (Stack c) = c
35 35
 
36 36
 instance Semigroup Stack where

+ 1
- 1
src/Day7/Parser.hs Näytä tiedosto

@@ -59,7 +59,7 @@ cd = do
59 59
   _ <- string "cd "
60 60
   name <- many $ noneOf "\n"
61 61
   _ <- char '\n'
62
-  return (nameToDir name)
62
+  return $ nameToDir name
63 63
 
64 64
 nameToDir :: DirName -> TerminalCommand
65 65
 nameToDir "/" = Root

+ 8
- 18
src/Lib.hs Näytä tiedosto

@@ -1,7 +1,7 @@
1 1
 module Lib
2 2
     ( someFunc
3 3
     ) where
4
-      
4
+
5 5
 import Day1
6 6
 import Day2
7 7
 import Day3
@@ -11,22 +11,12 @@ import Day6
11 11
 import Day7
12 12
 import Day8
13 13
 
14
+days :: [IO ()]
15
+days = [day1, day2, day3, day4, day5, day6, day7, day8]
16
+
17
+sep :: IO ()
18
+sep = putStrLn "---------"
19
+
14 20
 someFunc :: IO ()
15
-someFunc = do
16
-  day1
17
-  putStrLn "-----------"
18
-  day2
19
-  putStrLn "-----------"
20
-  day3
21
-  putStrLn "-----------"
22
-  day4
23
-  putStrLn "-----------"
24
-  day5
25
-  putStrLn "-----------"
26
-  day6
27
-  putStrLn "-----------"
28
-  day7
29
-  putStrLn "-----------"
30
-  day8
21
+someFunc = mapM_ (>> sep) days
31 22
   
32
-

Loading…
Peruuta
Tallenna