Commit b4107e8d1c66fae385337b5e7d7ceb5f9d1e45ba Parent: f74439ab3c9e9a901879ebe1829af7bd76d451c0 Author: mcol <mcol@posteo.net> Date: 2022-04-24 20:05:01 +0100 Committer: mcol <mcol@posteo.net> Committed: 2022-04-24 20:05:01 +0100 simplify findFile using Data.List.find
src/Repositories.hs Modified
@@ -22,6 +22,7 @@ import Data.Either (isRight) import qualified Data.HashMap.Strict as HashMap import Data.IORef (IORef, modifyIORef, newIORef, readIORef, writeIORef) +import Data.List (find) import Data.Maybe (catMaybes, fromJust, listToMaybe, mapMaybe) import Data.Tagged (Tagged (..), untag) import Data.Text (Text) @@ -184,10 +185,7 @@ -- Find a file in the tree starting with the specified prefix. The prefix is looked -- for on the full path, so will only find files in the top level directory. findFile :: Text -> [TreeFile] -> Maybe TreeFile - findFile _ [] = Nothing - findFile prefix (f : fs) = if isReadme f then Just f else findFile prefix fs - where - isReadme = T.isPrefixOf prefix . T.toLower . treeFilePath + findFile prefix = find (T.isPrefixOf prefix . T.toLower . treeFilePath) {- Collect commit history up to a head.