Skip to content

Commit

Permalink
Use strict foldlWithKey'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav committed Dec 9, 2023
1 parent d973484 commit f2a4e41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Dictionary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ searchTranslation :: Text -> DictionaryMeta -> Maybe Answer
searchTranslation query dm =
if null ts then Nothing else Just $ Answer ts dm.number dm.title
where
ts = HMS.foldrWithKey search [] dm.dictionary
search :: Text -> [Target] -> [Target] -> [Target]
search q v acc = if q == query then v <> acc else acc
ts = HMS.foldlWithKey' search [] dm.dictionary
search :: [Target] -> Text -> [Target] -> [Target]
search acc q v = if q == query then v <> acc else acc

sortOutput :: [Answer] -> [Answer]
sortOutput = sortBy (\a1 a2-> compare a1.dictNumber a2.dictNumber)
Expand Down
2 changes: 1 addition & 1 deletion src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ getFilesTexts fp = do
txts <- sequenceA contents
if length paths == length txts
then pure $ zip paths txts
else throwError $ UnknownError "Not all dictionary files was read successfully"
else throwError $ UnknownError "Some dictionary files fails to be read"

fromEither :: (Error HibetError :> es)
=> Either HibetError a
Expand Down

0 comments on commit f2a4e41

Please sign in to comment.