diff options
author | stuebinm | 2021-09-23 03:11:28 +0200 |
---|---|---|
committer | stuebinm | 2021-09-23 03:11:28 +0200 |
commit | 04b98e4d62fe33b4fa357f2b52ffcc4f2c413302 (patch) | |
tree | e934d34f8f4d5ba99c617dc3e7b664ef20732e96 /lib/CheckDir.hs | |
parent | 7e77e6335bab772c4be1b3f0594113d09cd4a366 (diff) |
some documentation
Diffstat (limited to '')
-rw-r--r-- | lib/CheckDir.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs index 753d5ab..f551e6a 100644 --- a/lib/CheckDir.hs +++ b/lib/CheckDir.hs @@ -32,11 +32,13 @@ setFromList = M.fromList . flip zip (repeat ()) listFromSet :: Set a -> [a] listFromSet = map fst . M.toList +-- | Result of linting an entire directory / repository data DirResult = DirResult { dirresultMaps :: Map FilePath MapResult , dirresultDeps :: [Text] } deriving (Generic, ToJSON) + instance PrettyPrint DirResult where prettyprint res = T.concat (map (\(p,lints) -> "\nin " <> T.pack p <> ":\n" <> prettyprint lints) $ M.toList $ dirresultMaps res) @@ -54,11 +56,18 @@ instance Monoid DirResult where } --- TODO: options? +-- | The nice function to check an entire repository with. +-- gets a prefix (i.e. the bare path to the repository) and +-- a root (i.e. the name of the file containing the entrypoint +-- map within that file) recursiveCheckDir :: FilePath -> FilePath -> IO DirResult recursiveCheckDir prefix root = recursiveCheckDir' prefix [root] mempty mempty - +-- | The less-nice function for checking an entire repository. +-- +-- Strictly speaking it probably doesn't need to have `done` and +-- `acc` since they are essentially the same thing, but doing it +-- like this seemed convenient at the time recursiveCheckDir' :: FilePath -> [FilePath] -> Set FilePath -> DirResult -> IO DirResult recursiveCheckDir' prefix paths done acc = do putStrLn $ "linting " <> show paths |