summary refs log tree commit diff
path: root/2/1.hs
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-12-02 19:35:02 +0200
committertzlil <tzlils@protonmail.com>2023-12-02 19:35:02 +0200
commitcd31a8035a378cf58242444f9068f7d441ff42a7 (patch)
tree0fede5d839cb6c2755662513e2737f803c461dae /2/1.hs
parent261bfbaa66c0293585c0d8f7ccb6fe4423bcad4e (diff)
make pointfree again
Diffstat (limited to '2/1.hs')
-rw-r--r--2/1.hs5
1 files changed, 1 insertions, 4 deletions
diff --git a/2/1.hs b/2/1.hs
index 1073b72..726f95c 100644
--- a/2/1.hs
+++ b/2/1.hs
@@ -8,7 +8,6 @@ import qualified Data.Map as M
 import Control.Monad
 
 data Color = Red | Green | Blue deriving (Show,Eq,Ord)
-type Handful = (Color, Int)
 type Set = M.Map Color Int
 type Game = (Int, [Set])
 
@@ -16,10 +15,8 @@ red = string "red" *>  pure Red
 green = string "green" *>  pure Green
 blue = string "blue" *>  pure Blue
 
-color :: Parser Color
 color = red <|> green <|> blue 
 
-handful :: Parser Handful
 handful = liftM2 (flip (,)) (space *> (read <$> many1 digit)) (space *> color)
 
 set = M.fromList <$> (sepBy handful $ string ",")
@@ -35,4 +32,4 @@ solution (i,m) = do
     guard $ M.findWithDefault 0 Blue m' <= 14
     return i
 
-main = head <$> getArgs >>= readFile >>= print . sum . catMaybes . map solution . either (error.show) id . parse games ""
\ No newline at end of file
+main = liftM2 (>>=) readFile (((print . sum . catMaybes . map solution . either (error.show) id) .) . parse games) =<< head <$> getArgs
\ No newline at end of file