Browse Source

Improve IO in Lib

main
Jens Kadenbach 2 years ago
parent
commit
e50555fe8b
3 changed files with 10 additions and 20 deletions
  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 View File

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

+ 1
- 1
src/Day7/Parser.hs View File

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

+ 8
- 18
src/Lib.hs View File

1
 module Lib
1
 module Lib
2
     ( someFunc
2
     ( someFunc
3
     ) where
3
     ) where
4
-      
4
+
5
 import Day1
5
 import Day1
6
 import Day2
6
 import Day2
7
 import Day3
7
 import Day3
11
 import Day7
11
 import Day7
12
 import Day8
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
 someFunc :: IO ()
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…
Cancel
Save