From 48a785ff972ccdd91f60866ec06ca32abe4d3203 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Mon, 31 Jul 2023 14:57:33 +0200 Subject: [PATCH] First attempt at implementation --- app/Main.hs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 9699dd1..364dfde 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -61,16 +61,12 @@ parseArgs (Args t dir h v c r) = do if not (null h) then putStr $ "\n\n" ++ h ++ "\n\n" else putStr "\n" - mkIndex r . filter (isSuffixOf ".gmi") =<< getDirectoryContents dir + mapM_ (mkIndex r) . filter (isSuffixOf ".gmi") =<< getDirectoryContents dir -mkIndex :: Bool -> [String] -> IO () -mkIndex True l = mapM_ (putStrLn . ("=> " ++)) l - -- where firstLine f = do - -- print $ head . lines =<< readFile f -mkIndex False l = mapM_ (putStrLn . ("=> " ++)) l - -firstLine :: FilePath -> IO () -firstLine f = do - putStr . head . lines =<< readFile f +mkIndex :: Bool -> FilePath -> IO () +mkIndex True l = do + line <- readFile l + putStrLn $ "=> " ++ l ++ (head . lines $ line) +mkIndex False l = putStrLn $ "=> " ++ l --compose = (++) <$> ("=> " ++) <*> (show . length) <*> (head . lines =<< readFile)