;check: uniqueleafnames: short circuit to avoid wasted work

This commit is contained in:
Simon Michael 2021-01-09 18:59:10 -08:00
parent b96713a584
commit 6931eec3ce

View File

@ -23,7 +23,9 @@ import Text.Printf (printf)
journalCheckUniqueleafnames :: Journal -> Either String ()
journalCheckUniqueleafnames j = do
-- find all duplicate leafnames, and the full account names they appear in
let dupes = finddupes $ journalLeafAndFullAccountNames j
case finddupes $ journalLeafAndFullAccountNames j of
[] -> Right ()
dupes ->
-- report the first posting that references one of them (and its position), for now
sequence_ $ map (checkposting dupes) $ journalPostings j